OSDN Git Service

Merge branch 'dev' of git://github.com/Bytom/bytom
[bytom/bytom-spv.git] / consensus / general.go
1 package consensus
2
3 import (
4         "strings"
5         "github.com/bytom/protocol/bc"
6 )
7
8 const (
9         // define the Max transaction size and Max block size
10         MaxTxSize    = uint64(1024)
11         MaxBlockSzie = uint64(16384)
12
13         //config parameter for coinbase reward
14         subsidyReductionInterval = uint64(560640)
15         baseSubsidy              = uint64(624000000000)
16         initialBlockSubsidy      = uint64(1470000000000000000)
17
18         // config for pow mining
19         powMinBits            = uint64(2161727821138738707)
20         BlocksPerRetarget     = uint64(1024)
21         targetSecondsPerBlock = uint64(60)
22 )
23
24 // define the BTM asset id, the soul asset of Bytom
25 var BTMAssetID = &bc.AssetID{
26         V0: uint64(18446744073709551615),
27         V1: uint64(18446744073709551615),
28         V2: uint64(18446744073709551615),
29         V3: uint64(18446744073709551615),
30 }
31
32 func BlockSubsidy(height uint64) uint64 {
33         if height == 1 {
34                 return initialBlockSubsidy
35         }
36         return baseSubsidy >> uint(height/subsidyReductionInterval)
37 }
38
39 func InitBlock() []byte {
40         return []byte("0301010000000000000000000000000000000000000000000000000000000000000000cecccaebf42b406b03545ed2b38a578e5e6b0796d4ebdd8a6dd72210873fcc026c7319de578ffc492159980684155da19e87de0d1b37b35c1a1123770ec1dcc710aabe77607cced7bb1993fcb680808080801e0107010700cecccaebf42b000001012cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8080ccdee2a69fb314010151000000")
41 }
42
43
44 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
45 // addresses on any default or registered network.  This is used when decoding
46 // an address string into a specific address type.
47 func IsBech32SegwitPrefix(prefix string,  params *Params) bool {
48         prefix = strings.ToLower(prefix)
49         if prefix == params.Bech32HRPSegwit+"1"  {
50                 return true
51         } else {
52                 return false
53         }
54 }
55
56
57 type Params struct {
58         // Name defines a human-readable identifier for the network.
59         Name string
60
61         Bech32HRPSegwit string
62
63 }
64
65
66 var MainNetParams = Params {
67         Name: "main",
68         Bech32HRPSegwit: "bm",
69 }
70
71
72 var TestNetParams = Params {
73         Name: "test",
74         Bech32HRPSegwit: "tm",
75 }
76