Skip to content

782 missing blocks fix #783

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 4 commits into from
Apr 27, 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
19 changes: 11 additions & 8 deletions core/service/blockMainService.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ type (
timestamp, totalAmount, totalFee, totalCoinBase int64,
transactions []*model.Transaction,
blockReceipts []*model.PublishedReceipt,
payloadHash []byte,
payloadLength uint32,
secretPhrase string,
) (*model.Block, error)
RemoveMempoolTransactions(transactions []*model.Transaction) error
Expand Down Expand Up @@ -639,6 +637,8 @@ func (bs *BlockService) PushBlock(previousBlock, block *model.Block, broadcast,

// ScanBlockPool scan the whole block pool to check if there are any block that's legal to be pushed yet
func (bs *BlockService) ScanBlockPool() error {
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlock)
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlock)
previousBlock, err := bs.GetLastBlock()
if err != nil {
return err
Expand All @@ -648,13 +648,16 @@ func (bs *BlockService) ScanBlockPool() error {
for index, block := range blocks {
err = bs.BlocksmithStrategy.CanPersistBlock(index, int64(len(blocksmithsMap)), previousBlock)
if err == nil {
err := func(block *model.Block) error {
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlock)
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlock)
err := bs.PushBlock(previousBlock, block, true, true)
return err
}(block)
err := bs.ValidateBlock(block, previousBlock)
if err != nil {
bs.Logger.Warnf("ScanBlockPool:blockValidationFail: %v\n", err)
return blocker.NewBlocker(
blocker.BlockErr, "ScanBlockPool:ValidateBlockFail",
)
}
err = bs.PushBlock(previousBlock, block, true, true)
if err != nil {
bs.Logger.Warnf("ScanBlockPool:PushBlockFail: %v\n", err)
return blocker.NewBlocker(
blocker.BlockErr, "ScanBlockPool:PushBlockFail",
)
Expand Down