• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision87a50cf38000cb22d2c6b6853675d79f4e85b4c9 (tree)
Time2019-09-09 15:34:32
Authorshenao78 <shenao.78@163....>
Commitershenao78

Log Message

fix mainchain keeper

Change Summary

Incremental Difference

--- a/toolbar/federation/synchron/mainchain_keeper.go
+++ b/toolbar/federation/synchron/mainchain_keeper.go
@@ -125,10 +125,9 @@ func (m *mainchainKeeper) isWithdrawalTx(tx *types.Tx) bool {
125125 }
126126 }
127127
128- if sourceTxHash := locateSideChainTx(tx.Outputs[len(tx.Outputs)-1]); sourceTxHash == "" {
129- return false
130- }
131- return true
128+ sourceTxHash := locateSideChainTx(tx.Outputs[len(tx.Outputs)-1])
129+ _, err := hex.DecodeString(sourceTxHash)
130+ return err == nil && len(sourceTxHash) == 64
132131 }
133132
134133 func locateSideChainTx(output *types.TxOutput) string {
@@ -257,7 +256,7 @@ func (m *mainchainKeeper) processWithdrawalTx(db *gorm.DB, block *types.Block, t
257256 blockHash := block.Hash()
258257 tx := block.Transactions[txIndex]
259258
260- stmt := db.Model(&orm.CrossTransaction{}).Where(&orm.CrossTransaction{
259+ return db.Model(&orm.CrossTransaction{}).Where(&orm.CrossTransaction{
261260 SourceTxHash: locateSideChainTx(tx.Outputs[len(tx.Outputs)-1]),
262261 Status: common.CrossTxPendingStatus,
263262 }).UpdateColumn(&orm.CrossTransaction{
@@ -267,15 +266,7 @@ func (m *mainchainKeeper) processWithdrawalTx(db *gorm.DB, block *types.Block, t
267266 DestTxIndex: sql.NullInt64{int64(txIndex), true},
268267 DestTxHash: sql.NullString{tx.ID.String(), true},
269268 Status: common.CrossTxCompletedStatus,
270- })
271- if stmt.Error != nil {
272- return stmt.Error
273- }
274-
275- if stmt.RowsAffected != 1 {
276- return ErrInconsistentDB
277- }
278- return nil
269+ }).Error
279270 }
280271
281272 func (m *mainchainKeeper) syncBlock() (bool, error) {
Show on old repository browser