OSDN Git Service

Add solo network
[bytom/bytom.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(10000000)
13         VMGasRate        = int64(200)
14         StorageGasRate   = int64(1)
15         MaxGasAmount     = int64(200000)
16         DefaultGasCredit = int64(30000)
17
18         //config parameter for coinbase reward
19         CoinbasePendingBlockNumber = uint64(100)
20         subsidyReductionInterval   = uint64(840000)
21         baseSubsidy                = uint64(41250000000)
22         InitialBlockSubsidy        = uint64(147000041250000000)
23
24         // config for pow mining
25         BlocksPerRetarget     = uint64(2016)
26         TargetSecondsPerBlock = uint64(150)
27         SeedPerRetarget       = uint64(256)
28
29         // MaxTimeOffsetSeconds is the maximum number of seconds a block time is allowed to be ahead of the current time
30         MaxTimeOffsetSeconds = uint64(60 * 60)
31         MedianTimeBlocks     = 11
32
33         PayToWitnessPubKeyHashDataSize = 20
34         PayToWitnessScriptHashDataSize = 32
35         CoinbaseArbitrarySizeLimit     = 128
36
37         BTMAlias = "BTM"
38 )
39
40 // BTMAssetID is BTM's asset id, the soul asset of Bytom
41 var BTMAssetID = &bc.AssetID{
42         V0: uint64(18446744073709551615),
43         V1: uint64(18446744073709551615),
44         V2: uint64(18446744073709551615),
45         V3: uint64(18446744073709551615),
46 }
47
48 // InitialSeed is SHA3-256 of Byte[0^32]
49 var InitialSeed = &bc.Hash{
50         V0: uint64(11412844483649490393),
51         V1: uint64(4614157290180302959),
52         V2: uint64(1780246333311066183),
53         V3: uint64(9357197556716379726),
54 }
55
56 // BTMDefinitionMap is the ....
57 var BTMDefinitionMap = map[string]interface{}{
58         "name":        BTMAlias,
59         "symbol":      BTMAlias,
60         "decimals":    8,
61         "description": `Bytom Official Issue`,
62 }
63
64 // BlockSubsidy calculate the coinbase rewards on given block height
65 func BlockSubsidy(height uint64) uint64 {
66         if height == 0 {
67                 return InitialBlockSubsidy
68         }
69         return baseSubsidy >> uint(height/subsidyReductionInterval)
70 }
71
72 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
73 // addresses on any default or registered network.  This is used when decoding
74 // an address string into a specific address type.
75 func IsBech32SegwitPrefix(prefix string, params *Params) bool {
76         prefix = strings.ToLower(prefix)
77         return prefix == params.Bech32HRPSegwit+"1"
78 }
79
80 // Params store the config for different network
81 type Params struct {
82         // Name defines a human-readable identifier for the network.
83         Name            string
84         Bech32HRPSegwit string
85 }
86
87 // ActiveNetParams is ...
88 var ActiveNetParams = MainNetParams
89
90 // NetParams is the correspondence between chain_id and Params
91 var NetParams = map[string]Params{
92         "mainnet": MainNetParams,
93         "testnet": TestNetParams,
94         "solonet": SoloNetParams,
95
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 }
109
110 // TestNetParams is the config for test-net
111 var SoloNetParams = Params{
112         Name:            "solo",
113         Bech32HRPSegwit: "sm",
114 }