OSDN Git Service

core upgrade (#310)
[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         // define the Max transaction size and Max block size
12         MaxTxSize    = uint64(1048576)
13         MaxBlockSzie = uint64(10485760)
14
15         //config parameter for coinbase reward
16         CoinbasePendingBlockNumber = uint64(6)
17         subsidyReductionInterval   = uint64(560640)
18         baseSubsidy                = uint64(624000000000)
19         InitialBlockSubsidy        = uint64(1470000000000000000)
20
21         // config for pow mining
22         PowMinBits            = uint64(2161727821138738707)
23         BlocksPerRetarget     = uint64(1024)
24         TargetSecondsPerBlock = uint64(60)
25
26         PayToWitnessPubKeyHashDataSize = 20
27         PayToWitnessScriptHashDataSize = 32
28
29         CoinbaseArbitrarySizeLimit = 128
30 )
31
32 // BTMAssetID is BTM's asset id, the soul asset of Bytom
33 var BTMAssetID = &bc.AssetID{
34         V0: uint64(18446744073709551615),
35         V1: uint64(18446744073709551615),
36         V2: uint64(18446744073709551615),
37         V3: uint64(18446744073709551615),
38 }
39
40 //BTMAlias is default btm
41 var BTMAlias = "btm"
42
43 //BTMSymbol
44 var BTMSymbol = "btm"
45
46 //BTMDecimals
47 var BTMDecimals = 8
48
49 //BTMDescription
50 var BTMDescription = `Bytom Official Issue`
51
52 //BTMDefinitionMap
53 var BTMDefinitionMap = map[string]interface{}{
54         "name":        BTMAlias,
55         "symbol":      BTMSymbol,
56         "decimals":    BTMDecimals,
57         "description": BTMDescription,
58 }
59
60 // BlockSubsidy calculate the coinbase rewards on given block height
61 func BlockSubsidy(height uint64) uint64 {
62         if height == 0 {
63                 return InitialBlockSubsidy
64         }
65         return baseSubsidy >> uint(height/subsidyReductionInterval)
66 }
67
68 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
69 // addresses on any default or registered network.  This is used when decoding
70 // an address string into a specific address type.
71 func IsBech32SegwitPrefix(prefix string, params *Params) bool {
72         prefix = strings.ToLower(prefix)
73         return prefix == params.Bech32HRPSegwit+"1"
74 }
75
76 // Params store the config for different network
77 type Params struct {
78         // Name defines a human-readable identifier for the network.
79         Name            string
80         Bech32HRPSegwit string
81 }
82
83 // MainNetParams is the config for production
84 var MainNetParams = Params{
85         Name:            "main",
86         Bech32HRPSegwit: "bm",
87 }
88
89 // TestNetParams is the config for test-net
90 var TestNetParams = Params{
91         Name:            "test",
92         Bech32HRPSegwit: "tm",
93 }