Skip to content

Commit

Permalink
fix miss cross chain msg when sync header (#1219)
Browse files Browse the repository at this point in the history
* fix miss cross chain msg when sync header

* Add some logs

* fixed

* gofmt
  • Loading branch information
tanZiWen authored May 29, 2020
1 parent d0686f5 commit 8a95f31
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion p2pserver/protocols/block_sync/block_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,14 @@ func (this *BlockSyncMgr) OnHeaderReceive(fromID p2pComm.PeerId, headers []*type
curHeaderHeight = this.ledger.GetCurrentHeaderHeight()
curBlockHeight := this.ledger.GetCurrentBlockHeight()
for _, header := range headers {
prevHeader, err := this.ledger.GetHeaderByHeight(header.Height - 1)
if err != nil {
log.Debugf("[block-sync] OnHeaderReceive GetHeaderByHeight error:%s", err)
continue
}
log.Debugf("[block-sync] OnHeaderReceive GetHeaderByHeight height:%d, prevHeader transaction root:%+v", header.Height-1, prevHeader.TransactionsRoot)
//handle empty block
if header.TransactionsRoot == common.UINT256_EMPTY {
if header.TransactionsRoot == common.UINT256_EMPTY && prevHeader.TransactionsRoot == common.UINT256_EMPTY {
log.Trace("[block-sync] OnHeaderReceive empty block Height:%d", header.Height)
height := header.Height
blockHash := header.Hash()
Expand Down

0 comments on commit 8a95f31

Please sign in to comment.