OSDN Git Service
(root)
/
bytom
/
vapor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
opt code
[bytom/vapor.git]
/
protocol
/
consensus_node_manager.go
diff --git
a/protocol/consensus_node_manager.go
b/protocol/consensus_node_manager.go
index
a4b59e6
..
4fe6638
100644
(file)
--- a/
protocol/consensus_node_manager.go
+++ b/
protocol/consensus_node_manager.go
@@
-49,25
+49,24
@@
func (c *consensusNodeManager) getBlocker(prevBlockHash *bc.Hash, timeStamp uint
}
startTimestamp := prevVoteRoundLastBlock.Timestamp + consensus.BlockTimeInterval
}
startTimestamp := prevVoteRoundLastBlock.Timestamp + consensus.BlockTimeInterval
-
+ order := getBlockerOrder(startTimestamp, timeStamp, uint64(len(consensusNodeMap)))
for xPub, consensusNode := range consensusNodeMap {
for xPub, consensusNode := range consensusNodeMap {
- begin := getLastBlockTimeInTimeRange(startTimestamp, timeStamp, consensusNode.Order, uint64(len(consensusNodeMap)))
- end := begin + consensus.BlockNumEachNode*consensus.BlockTimeInterval
- if timeStamp >= begin && timeStamp < end {
+ if consensusNode.Order == order {
return xPub, nil
}
}
return xPub, nil
}
}
+
// impossible occur
return "", errors.New("can not find blocker by given timestamp")
}
// impossible occur
return "", errors.New("can not find blocker by given timestamp")
}
-func get
LastBlockTimeInTimeRange(startTimestamp, endTimestamp, order
, numOfConsensusNode uint64) uint64 {
+func get
BlockerOrder(startTimestamp, blockTimestamp
, numOfConsensusNode uint64) uint64 {
// One round of product block time for all consensus nodes
roundBlockTime := consensus.BlockNumEachNode * numOfConsensusNode * consensus.BlockTimeInterval
// The start time of the last round of product block
// One round of product block time for all consensus nodes
roundBlockTime := consensus.BlockNumEachNode * numOfConsensusNode * consensus.BlockTimeInterval
// The start time of the last round of product block
- lastRoundStartTime := startTimestamp + (
end
Timestamp-startTimestamp)/roundBlockTime*roundBlockTime
- //
The time of product block of the consensus in last round
- return
lastRoundStartTime + order*
(consensus.BlockNumEachNode*consensus.BlockTimeInterval)
+ lastRoundStartTime := startTimestamp + (
block
Timestamp-startTimestamp)/roundBlockTime*roundBlockTime
+ //
Order of blocker
+ return
(blockTimestamp - lastRoundStartTime)/
(consensus.BlockNumEachNode*consensus.BlockTimeInterval)
}
func (c *consensusNodeManager) getPrevRoundLastBlock(prevBlockHash *bc.Hash) (*state.BlockNode, error) {
}
func (c *consensusNodeManager) getPrevRoundLastBlock(prevBlockHash *bc.Hash) (*state.BlockNode, error) {