OSDN Git Service

fix for golint
[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(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         PowMinBits            = uint64(2305843009213861724)
26         BlocksPerRetarget     = uint64(2016)
27         TargetSecondsPerBlock = uint64(150)
28         SeedPerRetarget       = uint64(256)
29
30         // MaxTimeOffsetSeconds is the maximum number of seconds a block time is allowed to be ahead of the current time
31         MaxTimeOffsetSeconds = uint64(60 * 60)
32         MedianTimeBlocks     = 11
33
34         PayToWitnessPubKeyHashDataSize = 20
35         PayToWitnessScriptHashDataSize = 32
36         CoinbaseArbitrarySizeLimit     = 128
37
38         BTMAlias = "BTM"
39 )
40
41 // BTMAssetID is BTM's asset id, the soul asset of Bytom
42 var BTMAssetID = &bc.AssetID{
43         V0: uint64(18446744073709551615),
44         V1: uint64(18446744073709551615),
45         V2: uint64(18446744073709551615),
46         V3: uint64(18446744073709551615),
47 }
48
49 // InitialSeed is SHA3-256 of Byte[0^32]
50 var InitialSeed = &bc.Hash{
51         V0: uint64(11412844483649490393),
52         V1: uint64(4614157290180302959),
53         V2: uint64(1780246333311066183),
54         V3: uint64(9357197556716379726),
55 }
56
57 // BTMDefinitionMap is the ....
58 var BTMDefinitionMap = map[string]interface{}{
59         "name":        BTMAlias,
60         "symbol":      BTMAlias,
61         "decimals":    8,
62         "description": `Bytom Official Issue`,
63 }
64
65 // BlockSubsidy calculate the coinbase rewards on given block height
66 func BlockSubsidy(height uint64) uint64 {
67         if height == 0 {
68                 return InitialBlockSubsidy
69         }
70         return baseSubsidy >> uint(height/subsidyReductionInterval)
71 }
72
73 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
74 // addresses on any default or registered network.  This is used when decoding
75 // an address string into a specific address type.
76 func IsBech32SegwitPrefix(prefix string, params *Params) bool {
77         prefix = strings.ToLower(prefix)
78         return prefix == params.Bech32HRPSegwit+"1"
79 }
80
81 // Params store the config for different network
82 type Params struct {
83         // Name defines a human-readable identifier for the network.
84         Name            string
85         Bech32HRPSegwit string
86 }
87
88 // ActiveNetParams is ...
89 var ActiveNetParams = MainNetParams
90
91 // NetParams is the correspondence between chain_id and Params
92 var NetParams = map[string]Params{
93         "mainnet": MainNetParams,
94         "testnet": TestNetParams,
95 }
96
97 // MainNetParams is the config for production
98 var MainNetParams = Params{
99         Name:            "main",
100         Bech32HRPSegwit: "bm",
101 }
102
103 // TestNetParams is the config for test-net
104 var TestNetParams = Params{
105         Name:            "test",
106         Bech32HRPSegwit: "tm",
107 }