OSDN Git Service

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