Skip to content

Commit

Permalink
bugfix: add to append queue if not append the parent block in service…
Browse files Browse the repository at this point in the history
… blocks
  • Loading branch information
gameofpointers committed Oct 3, 2023
1 parent cc9811e commit b2e5c66
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,23 @@ func (c *Core) serviceBlocks(hashNumberList []types.HashAndNumber) {
c.appendQueue.Add(block.Hash(), numberAndRetryCounter)
}
}
parentHeader := c.sl.hc.GetHeaderOrCandidate(block.ParentHash(), block.NumberU64()-1)
if parentHeader != nil {
parentBlock := c.sl.hc.GetBlockOrCandidate(block.ParentHash(), block.NumberU64()-1)
if parentBlock != nil {
// If parent header is dom, send a signal to dom to request for the block if it doesnt have it
_, parentHeaderOrder, err := c.sl.engine.CalcOrder(parentHeader)
_, parentHeaderOrder, err := c.sl.engine.CalcOrder(parentBlock.Header())
if err != nil {
log.Warn("Error calculating the parent block order in serviceBlocks", "Hash", parentHeader.Hash(), "Number", parentHeader.NumberArray())
log.Warn("Error calculating the parent block order in serviceBlocks", "Hash", parentBlock.Hash(), "Number", parentBlock.Header().NumberArray())
continue
}
nodeCtx := common.NodeLocation.Context()
if parentHeaderOrder < nodeCtx && c.GetHeaderByHash(parentHeader.Hash()) == nil {
log.Info("Requesting the dom to get the block if it doesnt have and try to append", "Hash", parentHeader.Hash(), "Order", parentHeaderOrder)
if parentHeaderOrder < nodeCtx && c.GetHeaderByHash(parentBlock.Hash()) == nil {
log.Info("Requesting the dom to get the block if it doesnt have and try to append", "Hash", parentBlock.Hash(), "Order", parentHeaderOrder)
if c.sl.domClient != nil {
// send a signal to the required dom to fetch the block if it doesnt have it, or its not in its appendqueue
go c.sl.domClient.RequestDomToAppendOrFetch(context.Background(), parentHeader.Hash(), parentHeader.ParentEntropy(), parentHeaderOrder)
go c.sl.domClient.RequestDomToAppendOrFetch(context.Background(), parentBlock.Hash(), parentBlock.ParentEntropy(), parentHeaderOrder)
}
}
c.addToQueueIfNotAppended(parentBlock)
c.InsertChain([]*types.Block{block})
} else {
c.sl.missingBlockFeed.Send(types.BlockRequest{Hash: block.ParentHash(), Entropy: block.ParentEntropy()})
Expand Down

0 comments on commit b2e5c66

Please sign in to comment.