X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=protocol%2Fbbft.go;fp=protocol%2Fbbft.go;h=f42e5f1a102ac6a81d50ce78c7d544d337c49d39;hb=571174f9f9a4e942512505e21dcfa7af06dc3613;hp=798f62da4fcf15d013b1b3c01d7611ba5f91fc17;hpb=b62a559ff00dffbffe1e2b87288e91f8908e6d04;p=bytom%2Fvapor.git diff --git a/protocol/bbft.go b/protocol/bbft.go index 798f62da..f42e5f1a 100644 --- a/protocol/bbft.go +++ b/protocol/bbft.go @@ -52,8 +52,17 @@ func (c *Chain) GetVoteResultByHash(blockHash *bc.Hash) (*state.VoteResult, erro } // IsBlocker returns whether the consensus node is a blocker at the specified time -func (c *Chain) IsBlocker(prevBlockHash *bc.Hash, pubkey string, timeStamp uint64) (bool, error) { - return c.consensusNodeManager.isBlocker(prevBlockHash, pubkey, timeStamp) +func (c *Chain) IsBlocker(prevBlockHash *bc.Hash, pubKey string, timeStamp uint64) (bool, error) { + xPub, err := c.consensusNodeManager.getBlocker(prevBlockHash, timeStamp) + if err != nil { + return false, err + } + return xPub == pubKey, nil +} + +// GetBlock return blocker by specified timestamp +func (c *Chain) GetBlocker(prevBlockHash *bc.Hash, timestamp uint64) (string, error) { + return c.consensusNodeManager.getBlocker(prevBlockHash, timestamp) } // ProcessBlockSignature process the received block signature messages @@ -122,7 +131,7 @@ func (c *Chain) validateSign(block *types.Block) error { return err } - isBlocker, err := c.consensusNodeManager.isBlocker(&block.PreviousBlockHash, pubKey, block.Timestamp) + isBlocker, err := c.IsBlocker(&block.PreviousBlockHash, pubKey, block.Timestamp) if err != nil { return err }