Documentation ¶
Index ¶
Constants ¶
const ( // Max gas that one block contains MaxBlockGas = uint64(10000000) VMGasRate = int64(200) StorageGasRate = int64(1) MaxGasAmount = int64(300000) // These configs need add to casper config in elegant way MaxNumOfValidators = int(10) InitBTMSupply = 169290721678579170 + 50000000000 RewardThreshold = 0.5 BlockReward = uint64(570776255) // config parameter for coinbase reward CoinbasePendingBlockNumber = uint64(10) MinVoteOutputAmount = uint64(100000000) PayToWitnessPubKeyHashDataSize = 20 PayToWitnessScriptHashDataSize = 32 BCRPContractHashDataSize = 32 CoinbaseArbitrarySizeLimit = 128 BCRPRequiredBTMAmount = uint64(100000000) BTMAlias = "BTM" )
consensus variables
Variables ¶
var ActiveNetParams = MainNetParams
ActiveNetParams is ...
var BTMAssetID = &bc.AssetID{ V0: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), V1: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), V2: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), }
BTMAssetID is BTM's asset id, the soul asset of Bystack
var BTMDefinitionMap = map[string]interface{}{ "name": BTMAlias, "symbol": BTMAlias, "decimals": 8, "description": `Bystack Official Issue`, }
BTMDefinitionMap is the ....
var MainNetParams = Params{ Name: "main", Bech32HRPSegwit: "bn", DefaultPort: "46657", DNSSeeds: []string{}, CasperConfig: CasperConfig{ BlockTimeInterval: 6000, MaxTimeOffsetMs: 3000, BlocksOfEpoch: 100, MinValidatorVoteNum: 1e14, VotePendingBlockNums: []VotePendingBlockNum{ {BeginBlock: 0, EndBlock: 432000, Num: 14400}, {BeginBlock: 432000, EndBlock: math.MaxUint64, Num: defaultVotePendingNum}, }, FederationXpubs: []chainkd.XPub{ xpub("021f661be770020bfae874ab6eeb3e403d18e03ef6b09b0583557f0e11b339f54e36bfd1a80ce0273cc966709f3751211be0a41a2afcb7f130b1b5ed679e8c8fc3"), }, }, }
MainNetParams is the config for production
var NetParams = map[string]Params{ "mainnet": MainNetParams, "wisdom": TestNetParams, "solonet": SoloNetParams, }
NetParams is the correspondence between chain_id and Params
var SoloNetParams = Params{ Name: "solo", Bech32HRPSegwit: "sn", CasperConfig: CasperConfig{ BlockTimeInterval: 6000, MaxTimeOffsetMs: 24000, BlocksOfEpoch: 100, MinValidatorVoteNum: 1e8, VotePendingBlockNums: []VotePendingBlockNum{{BeginBlock: 0, EndBlock: math.MaxUint64, Num: 10}}, FederationXpubs: []chainkd.XPub{}, }, }
SoloNetParams is the config for test-net
var TestNetParams = Params{ Name: "test", Bech32HRPSegwit: "tn", DefaultPort: "46656", DNSSeeds: []string{}, CasperConfig: CasperConfig{ BlockTimeInterval: 6000, MaxTimeOffsetMs: 3000, BlocksOfEpoch: 100, MinValidatorVoteNum: 1e8, VotePendingBlockNums: []VotePendingBlockNum{{BeginBlock: 0, EndBlock: math.MaxUint64, Num: 10}}, FederationXpubs: []chainkd.XPub{}, }, }
TestNetParams is the config for test-net
Functions ¶
func InitActiveNetParams ¶
InitActiveNetParams load the config by chain ID
func IsBech32SegwitPrefix ¶
IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit addresses on any default or registered network. This is used when decoding an address string into a specific address type.
func VotePendingBlockNums ¶
Types ¶
type CasperConfig ¶
type CasperConfig struct { // BlockTimeInterval, milliseconds, the block time interval for producing a block BlockTimeInterval uint64 // MaxTimeOffsetMs represent the max number of seconds a block time is allowed to be ahead of the current time MaxTimeOffsetMs uint64 // BlocksOfEpoch represent the block num in one epoch BlocksOfEpoch uint64 // MinValidatorVoteNum is the minimum vote number of become validator MinValidatorVoteNum uint64 // VotePendingBlockNumber is the locked block number of vote utxo VotePendingBlockNums []VotePendingBlockNum FederationXpubs []chainkd.XPub }
type Params ¶
type Params struct { // Name defines a human-readable identifier for the network. Name string Bech32HRPSegwit string // DefaultPort defines the default peer-to-peer port for the network. DefaultPort string // DNSSeeds defines a list of DNS seeds for the network that are used // as one method to discover peers. DNSSeeds []string // CasperConfig defines the casper consensus parameters CasperConfig }
Params store the config for different network
type ServiceFlag ¶
type ServiceFlag uint64
ServiceFlag use uint64 to indicate what kind of server this node can provide. one uint64 can represent 64 type of service flag
const ( // SFFullNode is a flag used to indicate a peer is a full node. SFFullNode ServiceFlag = 1 << iota // SFFastSync indicate peer support header first mode SFFastSync // SFSPV indicate peer support spv mode SFSPV // DefaultServices is the server that this node support DefaultServices = SFFullNode | SFFastSync | SFSPV )
func (ServiceFlag) IsEnable ¶
func (f ServiceFlag) IsEnable(checkFlag ServiceFlag) bool
IsEnable check does the flag support the input flag function