OSDN Git Service

low the gas rate
[bytom/bytom-spv.git] / consensus / general.go
1 package consensus
2
3 import (
4         "strings"
5
6         "github.com/bytom/protocol/bc"
7 )
8
9 //consensus variables
10 const (
11         // Max gas that one block contains
12         MaxBlockGas = uint64(100000000)
13
14         //config parameter for coinbase reward
15         CoinbasePendingBlockNumber = uint64(6)
16         subsidyReductionInterval   = uint64(560640)
17         baseSubsidy                = uint64(41250000000)
18         InitialBlockSubsidy        = uint64(1470000000000000000)
19
20         // config for pow mining
21         PowMinBits            = uint64(2305843009213861724)
22         BlocksPerRetarget     = uint64(128)
23         TargetSecondsPerBlock = uint64(60)
24         SeedPerRetarget       = uint64(128)
25
26         // MaxTimeOffsetSeconds is the maximum number of seconds a block time is allowed to be ahead of the current time
27         MaxTimeOffsetSeconds = uint64(60 * 60)
28         MedianTimeBlocks     = 11
29
30         PayToWitnessPubKeyHashDataSize = 20
31         PayToWitnessScriptHashDataSize = 32
32
33         CoinbaseArbitrarySizeLimit = 128
34
35         VMGasRate        = int64(100)
36         StorageGasRate   = int64(5)
37         MaxGasAmount     = int64(100000)
38         DefaultGasCredit = int64(80000)
39
40         BTMAlias = "BTM"
41 )
42
43 // BTMAssetID is BTM's asset id, the soul asset of Bytom
44 var BTMAssetID = &bc.AssetID{
45         V0: uint64(18446744073709551615),
46         V1: uint64(18446744073709551615),
47         V2: uint64(18446744073709551615),
48         V3: uint64(18446744073709551615),
49 }
50
51 // InitialSeed is SHA3-256 of Byte[0^32]
52 var InitialSeed = &bc.Hash{
53         V0: uint64(11412844483649490393),
54         V1: uint64(4614157290180302959),
55         V2: uint64(1780246333311066183),
56         V3: uint64(9357197556716379726),
57 }
58
59 // BTMDefinitionMap is the ....
60 var BTMDefinitionMap = map[string]interface{}{
61         "name":        BTMAlias,
62         "symbol":      BTMAlias,
63         "decimals":    8,
64         "description": `Bytom Official Issue`,
65 }
66
67 // BlockSubsidy calculate the coinbase rewards on given block height
68 func BlockSubsidy(height uint64) uint64 {
69         if height == 0 {
70                 return InitialBlockSubsidy
71         }
72         return baseSubsidy >> uint(height/subsidyReductionInterval)
73 }
74
75 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
76 // addresses on any default or registered network.  This is used when decoding
77 // an address string into a specific address type.
78 func IsBech32SegwitPrefix(prefix string, params *Params) bool {
79         prefix = strings.ToLower(prefix)
80         return prefix == params.Bech32HRPSegwit+"1"
81 }
82
83 // Params store the config for different network
84 type Params struct {
85         // Name defines a human-readable identifier for the network.
86         Name            string
87         Bech32HRPSegwit string
88 }
89
90 var ActiveNetParams = MainNetParams
91
92 // NetParams is the correspondence between chain_id and Params
93 var NetParams = map[string]Params{
94         "mainnet": MainNetParams,
95         "testnet": TestNetParams,
96 }
97
98 // MainNetParams is the config for production
99 var MainNetParams = Params{
100         Name:            "main",
101         Bech32HRPSegwit: "bm",
102 }
103
104 // TestNetParams is the config for test-net
105 var TestNetParams = Params{
106         Name:            "test",
107         Bech32HRPSegwit: "tm",
108 }