OSDN Git Service

versoin1.1.9 (#594)
[bytom/vapor.git] / consensus / general.go
index 32620ac..ec6c6cf 100644 (file)
@@ -2,8 +2,9 @@ package consensus
 
 import (
        "encoding/binary"
+       "fmt"
 
-       "github.com/vapor/protocol/bc"
+       "github.com/bytom/vapor/protocol/bc"
 )
 
 // basic constant
@@ -12,6 +13,11 @@ const (
 
        PayToWitnessPubKeyHashDataSize = 20
        PayToWitnessScriptHashDataSize = 32
+
+       CrossInForkHeight = 128957600
+
+       _ = iota
+       SoftFork001
 )
 
 // BTMAssetID is BTM's asset id, the soul asset of Bytom
@@ -71,6 +77,13 @@ type ProducerSubsidy struct {
        Subsidy    uint64
 }
 
+// MovRewardProgram is a reward address corresponding to the range of the specified block height when matching transactions
+type MovRewardProgram struct {
+       BeginBlock uint64
+       EndBlock   uint64
+       Program    string
+}
+
 // Params store the config for different network
 type Params struct {
        // Name defines a human-readable identifier for the network.
@@ -97,6 +110,14 @@ type Params struct {
 
        // ProducerSubsidys defines the producer subsidy by block height
        ProducerSubsidys []ProducerSubsidy
+
+       SoftForkPoint map[uint64]uint64
+
+       // Mov will only start when the block height is greater than this value
+       MovStartHeight uint64
+
+       // Used to receive rewards for matching transactions
+       MovRewardPrograms []MovRewardProgram
 }
 
 // ActiveNetParams is the active NetParams
@@ -137,6 +158,16 @@ var MainNetParams = Params{
        Checkpoints: []Checkpoint{},
        ProducerSubsidys: []ProducerSubsidy{
                {BeginBlock: 1, EndBlock: 63072000, Subsidy: 9512938},
+               {BeginBlock: 63072001, EndBlock: 126144000, Subsidy: 9512938},
+       },
+       SoftForkPoint:  map[uint64]uint64{SoftFork001: 10461600},
+       MovStartHeight: 42884800,
+       MovRewardPrograms: []MovRewardProgram{
+               {
+                       BeginBlock: 1,
+                       EndBlock:   126144000,
+                       Program:    "00141d00f85e220e35a23282cfc7f91fe7b34bf6dc18",
+               },
        },
 }
 
@@ -148,12 +179,12 @@ var TestNetParams = Params{
        DNSSeeds:        []string{"www.testnetseed.vapor.io"},
        BasicConfig: BasicConfig{
                MaxBlockGas:                uint64(10000000),
-               MaxGasAmount:               int64(200000),
+               MaxGasAmount:               int64(640000),
                DefaultGasCredit:           int64(160000),
                StorageGasRate:             int64(1),
                VMGasRate:                  int64(200),
-               VotePendingBlockNumber:     uint64(10000),
-               CoinbasePendingBlockNumber: uint64(1200),
+               VotePendingBlockNumber:     uint64(3456000),
+               CoinbasePendingBlockNumber: uint64(7200),
                CoinbaseArbitrarySizeLimit: 128,
        },
        DPOSConfig: DPOSConfig{
@@ -216,12 +247,21 @@ func BlockSubsidy(height uint64) uint64 {
 
 // BytomMainNetParams is the config for bytom mainnet
 func BytomMainNetParams(vaporParam *Params) *Params {
-       bech32HRPSegwit := "sm"
+       bech32HRPSegwit := "sn"
        switch vaporParam.Name {
        case "main":
-               bech32HRPSegwit = "bm"
+               bech32HRPSegwit = "bn"
        case "test":
-               bech32HRPSegwit = "tm"
+               bech32HRPSegwit = "tn"
        }
        return &Params{Bech32HRPSegwit: bech32HRPSegwit}
 }
+
+// InitActiveNetParams load the config by chain ID
+func InitActiveNetParams(chainID string) error {
+       var exist bool
+       if ActiveNetParams, exist = NetParams[chainID]; !exist {
+               return fmt.Errorf("chain_id[%v] don't exist", chainID)
+       }
+       return nil
+}