Golang implemented sidechain for Bytom
Revision | cf13a1d9a87cac11edbcaec14c9bd90abfc70667 (tree) |
---|---|
Time | 2019-06-13 12:17:59 |
Author | Chengcheng Zhang <943420582@qq.c...> |
Commiter | Chengcheng Zhang |
update
@@ -23,11 +23,11 @@ const ( | ||
23 | 23 | VotePendingBlockNumber = uint64(10000) |
24 | 24 | |
25 | 25 | //DPOS parameter |
26 | - NumOfConsensusNode = 10 | |
27 | - BlockNumEachNode = 12 | |
28 | - RoundVoteBlockNums = NumOfConsensusNode * BlockNumEachNode * 10 | |
29 | - MinVoteNum = 10000000 | |
30 | - MinVoteOutputAmount = uint64(100000000) | |
26 | + NumOfConsensusNode = 10 | |
27 | + BlockNumEachNode = 12 | |
28 | + RoundVoteBlockNums = NumOfConsensusNode * BlockNumEachNode * 10 | |
29 | + MinConsensusNodeVoteNum = uint64(100000000000000) // min is 1 million BTM | |
30 | + MinVoteOutputAmount = uint64(100000000) // min is 1 BTM | |
31 | 31 | |
32 | 32 | // BlockTimeInterval indicate product one block per 500 milliseconds |
33 | 33 | BlockTimeInterval = 500 |
@@ -4,8 +4,8 @@ import ( | ||
4 | 4 | "encoding/hex" |
5 | 5 | "sort" |
6 | 6 | |
7 | - "github.com/vapor/consensus" | |
8 | 7 | "github.com/vapor/config" |
8 | + "github.com/vapor/consensus" | |
9 | 9 | "github.com/vapor/crypto/ed25519/chainkd" |
10 | 10 | "github.com/vapor/errors" |
11 | 11 | "github.com/vapor/math/checked" |
@@ -96,7 +96,7 @@ func (v *VoteResult) ApplyBlock(block *types.Block) error { | ||
96 | 96 | func (v *VoteResult) ConsensusNodes() (map[string]*ConsensusNode, error) { |
97 | 97 | var nodes []*ConsensusNode |
98 | 98 | for pubkey, voteNum := range v.NumOfVote { |
99 | - if voteNum >= consensus.MinVoteNum { | |
99 | + if voteNum >= consensus.MinConsensusNodeVoteNum { | |
100 | 100 | var xpub chainkd.XPub |
101 | 101 | if err := xpub.UnmarshalText([]byte(pubkey)); err != nil { |
102 | 102 | return nil, err |
@@ -113,7 +113,7 @@ func (v *VoteResult) ConsensusNodes() (map[string]*ConsensusNode, error) { | ||
113 | 113 | nodes[i].Order = uint64(i) |
114 | 114 | result[nodes[i].XPub.String()] = nodes[i] |
115 | 115 | } |
116 | - | |
116 | + | |
117 | 117 | if len(result) != 0 { |
118 | 118 | return result, nil |
119 | 119 | } |
@@ -237,8 +237,8 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { | ||
237 | 237 | if err = checkValidSrc(&vs2, e.Source); err != nil { |
238 | 238 | return errors.Wrap(err, "checking vote output source") |
239 | 239 | } |
240 | - if err = checkVoteOutputAmount(e.Source); err != nil { | |
241 | - return errors.Wrap(err, "checking vote output amount") | |
240 | + if e.Source.Value.Amount < consensus.MinVoteOutputAmount { | |
241 | + return ErrVoteOutputAmount | |
242 | 242 | } |
243 | 243 | |
244 | 244 | case *bc.Retirement: |
@@ -575,10 +575,3 @@ func ValidateTx(tx *bc.Tx, block *bc.Block) (*GasState, error) { | ||
575 | 575 | } |
576 | 576 | return vs.gasStatus, checkValid(vs, tx.TxHeader) |
577 | 577 | } |
578 | - | |
579 | -func checkVoteOutputAmount(vs *bc.ValueSource) error { | |
580 | - if vs.Value.Amount < consensus.MinVoteOutputAmount { | |
581 | - return ErrVoteOutputAmount | |
582 | - } | |
583 | - return nil | |
584 | -} |