• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版907f75b076ffd7bfccb7227b0cd0f493cf9f75d9 (tree)
时间2019-06-03 17:57:59
作者Paladz <yzhu101@uott...>
CommiterGitHub

Log Message

Merge branch 'v0.1' into merge_bbft

更改概述

差异

--- a/blockchain/query/annotated.go
+++ b/blockchain/query/annotated.go
@@ -53,6 +53,7 @@ type AnnotatedOutput struct {
5353 AccountAlias string `json:"account_alias,omitempty"`
5454 ControlProgram chainjson.HexBytes `json:"control_program"`
5555 Address string `json:"address,omitempty"`
56+ Vote chainjson.HexBytes `json:"vote,omitempty"`
5657 }
5758
5859 //AnnotatedAccount means an annotated account.
--- a/protocol/consensus_node_manager.go
+++ b/protocol/consensus_node_manager.go
@@ -56,11 +56,12 @@ func (c *consensusNodeManager) getConsensusNode(prevBlockHash *bc.Hash, pubkey s
5656 }
5757
5858 func (c *consensusNodeManager) isBlocker(prevBlockHash *bc.Hash, pubKey string, timeStamp uint64) (bool, error) {
59- consensusNode, err := c.getConsensusNode(prevBlockHash, pubKey)
60- if err != nil && err != errNotFoundConsensusNode {
59+ consensusNodeMap, err := c.getConsensusNodesByVoteResult(prevBlockHash)
60+ if err != nil {
6161 return false, err
6262 }
6363
64+ consensusNode := consensusNodeMap[pubKey]
6465 if consensusNode == nil {
6566 return false, nil
6667 }
@@ -71,14 +72,14 @@ func (c *consensusNodeManager) isBlocker(prevBlockHash *bc.Hash, pubKey string,
7172 }
7273
7374 startTimestamp := prevVoteRoundLastBlock.Timestamp + consensus.BlockTimeInterval
74- begin := getLastBlockTimeInTimeRange(startTimestamp, timeStamp, consensusNode.order)
75+ begin := getLastBlockTimeInTimeRange(startTimestamp, timeStamp, consensusNode.order, len(consensusNodeMap))
7576 end := begin + consensus.BlockNumEachNode*consensus.BlockTimeInterval
7677 return timeStamp >= begin && timeStamp < end, nil
7778 }
7879
79-func getLastBlockTimeInTimeRange(startTimestamp, endTimestamp, order uint64) uint64 {
80+func getLastBlockTimeInTimeRange(startTimestamp, endTimestamp, order uint64, numOfConsensusNode int) uint64 {
8081 // One round of product block time for all consensus nodes
81- roundBlockTime := uint64(consensus.BlockNumEachNode * consensus.NumOfConsensusNode * consensus.BlockTimeInterval)
82+ roundBlockTime := uint64(consensus.BlockNumEachNode * numOfConsensusNode * consensus.BlockTimeInterval)
8283 // The start time of the last round of product block
8384 lastRoundStartTime := startTimestamp + (endTimestamp-startTimestamp)/roundBlockTime*roundBlockTime
8485 // The time of product block of the consensus in last round
--- a/wallet/annotated.go
+++ b/wallet/annotated.go
@@ -16,7 +16,6 @@ import (
1616 dbm "github.com/vapor/database/leveldb"
1717 "github.com/vapor/protocol/bc"
1818 "github.com/vapor/protocol/bc/types"
19- "github.com/vapor/protocol/vm/vmutil"
2019 )
2120
2221 // annotateTxs adds asset data to transactions
@@ -248,10 +247,15 @@ func (w *Wallet) BuildAnnotatedOutput(tx *types.Tx, idx int) *query.AnnotatedOut
248247 Address: w.getAddressFromControlProgram(orig.ControlProgram()),
249248 }
250249
251- if vmutil.IsUnspendable(out.ControlProgram) {
252- out.Type = "retire"
253- } else {
250+ switch e := tx.Entries[*outid].(type) {
251+ case *bc.IntraChainOutput:
254252 out.Type = "control"
253+ case *bc.CrossChainOutput:
254+ out.Type = "cross_Output"
255+ case *bc.VoteOutput:
256+ out.Type = "vote"
257+ out.Vote = e.Vote
255258 }
259+
256260 return out
257261 }
Show on old repository browser