Skip to content

Commit

Permalink
fix(lib/babe): call AddBlock in BABE synchronously (#1585)
Browse files Browse the repository at this point in the history
  • Loading branch information
noot authored May 14, 2021
1 parent eef03c6 commit 86acc43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 1 addition & 6 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,7 @@ func (s *Service) handleReceivedBlock(block *types.Block) (err error) {
return ErrNilBlockState
}

err = s.blockState.AddBlock(block)
if err != nil {
return err
}

logger.Debug("added block from BABE", "header", block.Header, "body", block.Body)
logger.Debug("got block from BABE", "header", block.Header, "body", block.Body)

msg := &network.BlockAnnounceMessage{
ParentHash: block.Header.ParentHash,
Expand Down
5 changes: 5 additions & 0 deletions lib/babe/babe.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ func (b *Service) handleSlot(slotNum uint64) error {
logger.Info("built block", "hash", hash.String(), "number", block.Header.Number, "slot", slotNum)
logger.Debug("built block", "header", block.Header, "body", block.Body, "parent", parent.Hash())

err = b.blockState.AddBlock(block)
if err != nil {
return err
}

err = b.safeSend(*block)
if err != nil {
logger.Error("failed to send block to core", "error", err)
Expand Down

0 comments on commit 86acc43

Please sign in to comment.