// the number of restored Tx should be very small or most of time ZERO
// Error returned from validation is ignored, tx could still be lost if validation fails.
// TODO: adjust tx timestamp so that it won't starve in pool.
- if _, err := c.ValidateTx(tx); err != nil {
+ if _, err := c.validateTx(tx, blockHeader); err != nil {
log.WithFields(log.Fields{"module": logModule, "tx_id": tx.Tx.ID.String(), "error": err}).Info("restore tx fail")
}
}
return err
}
- if err := consensusResult.AttachCoinbaseReward(block); err != nil {
- return err
- }
-
- rewards, err := consensusResult.GetCoinbaseRewards(block.Height)
+ rewards, err := consensusResult.GetCoinbaseRewards(parent.Height)
if err != nil {
return err
}
func (c *Chain) processBlock(block *types.Block) (bool, error) {
blockHash := block.Hash()
if c.BlockExist(&blockHash) {
- log.WithFields(log.Fields{"module": logModule, "hash": blockHash.String(), "height": block.Height}).Info("block has been processed")
+ log.WithFields(log.Fields{"module": logModule, "hash": blockHash.String(), "height": block.Height}).Debug("block has been processed")
return c.orphanManage.BlockExist(&blockHash), nil
}
+ c.markTransactions(block.Transactions...)
+
if _, err := c.store.GetBlockHeader(&block.PreviousBlockHash); err != nil {
c.orphanManage.Add(block)
return true, nil