OSDN Git Service

modify timestamp (#252)
[bytom/vapor.git] / consensus / general.go
index 868fc5b..da54f95 100644 (file)
@@ -14,21 +14,26 @@ const (
        VMGasRate        = int64(200)
        StorageGasRate   = int64(1)
        MaxGasAmount     = int64(200000)
-       DefaultGasCredit = int64(30000)
+       DefaultGasCredit = int64(160000)
 
        //config parameter for coinbase reward
        CoinbasePendingBlockNumber = uint64(100)
-       subsidyReductionInterval   = uint64(840000)
-       baseSubsidy                = uint64(41250000000)
-       InitialBlockSubsidy        = uint64(140700041250000000)
 
-       // config for pow mining
-       BlocksPerRetarget     = uint64(2016)
-       TargetSecondsPerBlock = uint64(150)
-       SeedPerRetarget       = uint64(256)
+       //config parameter for vote
+       VotePendingBlockNumber = uint64(10000)
+
+       //DPOS parameter
+       NumOfConsensusNode      = 10
+       BlockNumEachNode        = 12
+       RoundVoteBlockNums      = NumOfConsensusNode * BlockNumEachNode * 10
+       MinConsensusNodeVoteNum = uint64(100000000000000) // min is 1 million BTM
+       MinVoteOutputAmount     = uint64(100000000)       // min is 1 BTM
+
+       // BlockTimeInterval indicate product one block per 500 milliseconds
+       BlockTimeInterval = 500
 
        // MaxTimeOffsetMs is the maximum number of seconds a block time is allowed to be ahead of the current time
-       MaxTimeOffsetMs  = uint64(60 * 60 * 1000)
+       MaxTimeOffsetMs  = uint64(BlockTimeInterval * BlockNumEachNode / 3)
        MedianTimeBlocks = 11
 
        PayToWitnessPubKeyHashDataSize = 20
@@ -46,14 +51,6 @@ var BTMAssetID = &bc.AssetID{
        V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
 }
 
-// InitialSeed is SHA3-256 of Byte[0^32]
-var InitialSeed = &bc.Hash{
-       V0: uint64(11412844483649490393),
-       V1: uint64(4614157290180302959),
-       V2: uint64(1780246333311066183),
-       V3: uint64(9357197556716379726),
-}
-
 // BTMDefinitionMap is the ....
 var BTMDefinitionMap = map[string]interface{}{
        "name":        BTMAlias,
@@ -64,10 +61,12 @@ var BTMDefinitionMap = map[string]interface{}{
 
 // BlockSubsidy calculate the coinbase rewards on given block height
 func BlockSubsidy(height uint64) uint64 {
-       if height == 0 {
-               return InitialBlockSubsidy
+       for _, subsidy := range ActiveNetParams.ProducerSubsidys {
+               if height >= subsidy.BeginBlock && height <= subsidy.EndBlock {
+                       return subsidy.Subsidy
+               }
        }
-       return baseSubsidy >> uint(height/subsidyReductionInterval)
+       return 0
 }
 
 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
@@ -86,6 +85,13 @@ type Checkpoint struct {
        Hash   bc.Hash
 }
 
+// ProducerSubsidy is a subsidy to the producer of the generated block
+type ProducerSubsidy struct {
+       BeginBlock uint64
+       EndBlock   uint64
+       Subsidy    uint64
+}
+
 // Params store the config for different network
 type Params struct {
        // Name defines a human-readable identifier for the network.
@@ -96,8 +102,9 @@ type Params struct {
 
        // DNSSeeds defines a list of DNS seeds for the network that are used
        // as one method to discover peers.
-       DNSSeeds    []string
-       Checkpoints []Checkpoint
+       DNSSeeds         []string
+       Checkpoints      []Checkpoint
+       ProducerSubsidys []ProducerSubsidy
 }
 
 // ActiveNetParams is ...
@@ -161,6 +168,12 @@ var SoloNetParams = Params{
        Name:            "solo",
        Bech32HRPSegwit: "sm",
        Checkpoints:     []Checkpoint{},
+       ProducerSubsidys: []ProducerSubsidy{
+               {BeginBlock: 0, EndBlock: 0, Subsidy: 24},
+               {BeginBlock: 1, EndBlock: 840000, Subsidy: 24},
+               {BeginBlock: 840001, EndBlock: 1680000, Subsidy: 12},
+               {BeginBlock: 1680001, EndBlock: 3360000, Subsidy: 6},
+       },
 }
 
 // VaporNetParams is the config for vapor-net
@@ -168,4 +181,7 @@ var VaporNetParams = Params{
        Name:            "vapor",
        Bech32HRPSegwit: "vp",
        Checkpoints:     []Checkpoint{},
+       ProducerSubsidys: []ProducerSubsidy{
+               {BeginBlock: 1, EndBlock: 63072000, Subsidy: 15000000},
+       },
 }