Advertisement
Guest User

simulator #8

a guest
Apr 3rd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 2.05 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "os"
  5.     "fmt"
  6.     "strconv"
  7.     "math/rand"
  8.     "math"
  9.     "flag"
  10. )
  11.  
  12.  
  13.  
  14. var block = 0//block count ( for genesis block = 0 )
  15.  
  16.  
  17. //var percent = 0.00000011946
  18. var pi = float64(3.1415926535897932384626433832795)
  19. var coef = float64(0.43429448190325182765112891891661)
  20. var year = 262980
  21.  
  22.  
  23. var percent_year = 0.0314159
  24. var percent_day_multi = math.Pow(1+percent_year, float64(1.0/365.0))
  25. var percent = (percent_day_multi - 1) / 720.0
  26.  
  27.  
  28. var Coin = int64(1000000)
  29. var Cent = int64(10000)
  30.  
  31. var mplus, wMplus, sMplus float64
  32.  
  33. var wDiff = float64(1.0)
  34. var sDiff = 0.0001
  35.  
  36. var supply = 0.0//moneysupply
  37. var fees = 0.0
  38.  
  39. var wHour = 29//PoW blocks' rate per 1 hour
  40. var shour = 1// PoS blocks' rate per 1 hour
  41.  
  42.  
  43. func main() {
  44.     flag.Parse()
  45.     wReward := 0.0
  46.     fl, _ := strconv.ParseInt(flag.Arg(0), 10, 8)
  47.  
  48. //years to mine in blocks
  49.     eot := year * int(fl) + 2
  50. //  fmt.Println(eot)
  51. //  os.Exit(0)
  52.     rnd := rand.New(rand.NewSource(7998884776666255876))
  53.     for {
  54.         if block < 10000000 {
  55.             wReward = 10.0 + coef * math.Log(wDiff)
  56. //          fmt.Println("PoW bounty: ", wReward, "wDiff=", wDiff)
  57.             if block > 10 { wDiff = (1.005 * wDiff + rnd.Float64() * 111111.0 + 1.0) / 2  }
  58.             if wDiff > 64000.0 { wDiff = 63999.0 }
  59.             block++
  60.         }
  61. //      if block >= 1000000 { wReward = 0.0 }
  62.         txFees := rnd.Float64() / 1.35
  63.         if txFees > 0.66 { txFees = 0.02 }
  64.         coinAge := rnd.Int63n(89970) + 30 //pseudorandom  coin_age in days
  65.         sReward := float64((33 * coinAge) / 12053) * 0.01
  66. //      fmt.Println("PoS: ", sReward, "Fees=", txFees)
  67. //      sRewardAndFees := sReward + txFees
  68.         block++
  69. //      fmt.Println("")
  70.         supply = supply + wReward + sReward
  71.         fees = fees + txFees
  72.         if (block % year) == 0 {
  73.             fmt.Println("moneysupply: ", strconv.FormatFloat(supply, 'f' , -1, 64), " at block #", block)
  74.             fmt.Println("tx_fees =", fees)
  75.             fmt.Println("PoW bounty: ", wReward, "wDiff=", wDiff)
  76.             fmt.Println("PoS: ", sReward, "Fees=", txFees)
  77.             fmt.Println("==========================================================")
  78.         }
  79.         if block > eot { break }
  80.     }
  81.    
  82.     os.Exit(0)
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement