dev: provide previous block number to UnauthorizedSignerError

This commit is contained in:
atvanguard 2020-05-18 14:17:13 +05:30
parent c7ea09a019
commit 1be0c4894a
2 changed files with 5 additions and 3 deletions

View file

@ -555,7 +555,8 @@ func (c *Bor) verifySeal(chain consensus.ChainReader, header *types.Header, pare
return err
}
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
return &UnauthorizedSignerError{number, signer.Bytes()}
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, signer.Bytes()}
}
succession, err := snap.GetSignerSuccessionNumber(signer)
@ -741,7 +742,8 @@ func (c *Bor) Seal(chain consensus.ChainReader, block *types.Block, results chan
// Bail out if we're unauthorized to sign a block
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
return &UnauthorizedSignerError{number, signer.Bytes()}
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, signer.Bytes()}
}
successionNumber, err := snap.GetSignerSuccessionNumber(signer)

View file

@ -185,5 +185,5 @@ func TestSignerNotFound(t *testing.T) {
_, err := chain.InsertChain([]*types.Block{block})
assert.Equal(t,
*err.(*bor.UnauthorizedSignerError),
bor.UnauthorizedSignerError{Number: 1, Signer: addr.Bytes()})
bor.UnauthorizedSignerError{Number: 0, Signer: addr.Bytes()})
}