Skip to content

handle smithing nil value #682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion core/service/blockMainService.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ func (bs *BlockService) PushBlock(previousBlock, block *model.Block, broadcast,
// get blocksmith index
blocksmithsMap := bs.BlocksmithStrategy.GetSortedBlocksmithsMap(previousBlock)
blocksmithIndex = blocksmithsMap[string(block.BlocksmithPublicKey)]
if blocksmithIndex == nil {
if rollbackErr := bs.QueryExecutor.RollbackTx(); rollbackErr != nil {
bs.Logger.Error(rollbackErr.Error())
}
return blocker.NewBlocker(blocker.BlockErr, "BlocksmithNotInSmithingList")
}
// handle if is first index
if *blocksmithIndex > 0 {
// check if current block is in pushable window
Expand Down Expand Up @@ -1486,7 +1492,9 @@ func (bs *BlockService) WillSmith(
blocksmithsMap := bs.BlocksmithStrategy.GetSortedBlocksmithsMap(lastBlock)
blocksmithIndex, ok := blocksmithsMap[string(blocksmith.NodePublicKey)]
if !ok {
return blockchainProcessorLastBlockID, err
return blockchainProcessorLastBlockID, blocker.NewBlocker(
blocker.BlockErr, "BlocksmithNotInSmithingList",
)
}
blockPool := bs.BlockPoolService.GetBlock(*blocksmithIndex)
if blockPool != nil {
Expand Down