add empty field check for cxreceiptproof

pull/1655/head
chao 5 years ago
parent 8aa0fff672
commit 63ffa3a766
  1. 5
      core/types/cx_receipt.go
  2. 6
      node/node.go

@ -179,3 +179,8 @@ func (cxp *CXReceiptsProof) GetToShardID() (uint32, error) {
}
return shardID, nil
}
// ContainsEmptyField checks whether the given CXReceiptsProof contains empty field
func (cxp *CXReceiptsProof) ContainsEmptyField() bool {
return cxp == nil || cxp.Receipts == nil || cxp.MerkleProof == nil || cxp.Header == nil || len(cxp.CommitSig)+len(cxp.CommitBitmap) == 0
}

@ -295,6 +295,12 @@ func (node *Node) AddPendingTransaction(newTx *types.Transaction) {
func (node *Node) AddPendingReceipts(receipts *types.CXReceiptsProof) {
node.pendingCXMutex.Lock()
defer node.pendingCXMutex.Unlock()
if receipts.ContainsEmptyField() {
utils.Logger().Info().Int("totalPendingReceipts", len(node.pendingCXReceipts)).Msg("CXReceiptsProof contains empty field")
return
}
blockNum := receipts.Header.Number().Uint64()
shardID := receipts.Header.ShardID()
key := utils.GetPendingCXKey(shardID, blockNum)

Loading…
Cancel
Save