// return err
// }
- if err := updateDeletedTransaction(db); err != nil {
- return err
- }
-
return bp.processChainInfo()
}
}
return outputs
}
-
-// An expired unconfirmed transaction will be marked as deleted, but the latter transaction was packaged into block,
-// the deleted_at flag must be removed. In addition, the gorm can't support update deleted_at field directly, can only use raw sql.
-func updateDeletedTransaction(db *gorm.DB) error {
- return db.Exec("UPDATE cross_transactions SET deleted_at = NULL WHERE block_height > 0 AND deleted_at IS NOT NULL").Error
-}
btmTypes "github.com/bytom/protocol/bc/types"
"github.com/jinzhu/gorm"
+ "github.com/vapor/errors"
"github.com/vapor/federation/config"
"github.com/vapor/federation/database/orm"
vaporTypes "github.com/vapor/protocol/bc/types"
}
func (p *detachBlockProcessor) processDepositFromMainchain(txIndex uint64, tx *btmTypes.Tx) error {
- return nil
+ ormTx := &orm.CrossTransaction{TxHash: tx.ID.String()}
+ if err := p.db.Where(tx).First(tx).Error; err != nil {
+ return errors.Wrap(err, "db query transaction")
+ }
+
+ if err := p.db.Delete(&orm.CrossTransactionInput{}, "MainchainTxID = ?", ormTx.ID).Error; err != nil {
+ return errors.Wrap(err, "db delete CrossTransactionInput")
+ }
+
+ return p.db.Delete(ormTx).Error
}
func (p *detachBlockProcessor) processIssuing(db *gorm.DB, txs []*btmTypes.Tx) error {