From: HAOYUatHZ Date: Fri, 14 Jun 2019 00:17:45 +0000 (+0800) Subject: clean up X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=a8b487c04505728c4550b72aed66c873bb338ec0 clean up --- diff --git a/federation/common/const.go b/federation/common/const.go index e843f9ef..0a91d33c 100644 --- a/federation/common/const.go +++ b/federation/common/const.go @@ -1,5 +1,9 @@ package common +import ( + "github.com/vapor/errors" +) + const ( CrossTxPendingStatus uint8 = iota CrossTxRejectedStatus @@ -12,3 +16,5 @@ const ( CrossTxSignCompletedStatus CrossTxSignRejectedStatus ) + +var ErrInconsistentDB = errors.New("inconsistent db status") diff --git a/federation/synchron/common.go b/federation/synchron/common.go deleted file mode 100644 index 0bfc2365..00000000 --- a/federation/synchron/common.go +++ /dev/null @@ -1,12 +0,0 @@ -package synchron - -import ( - vaporCfg "github.com/vapor/config" - "github.com/vapor/errors" -) - -var ( - fedProg = vaporCfg.FederationProgrom(vaporCfg.CommonConfig) - - ErrInconsistentDB = errors.New("inconsistent db status") -) diff --git a/federation/synchron/mainchain_keeper.go b/federation/synchron/mainchain_keeper.go index f0a7fd8f..13a315fe 100644 --- a/federation/synchron/mainchain_keeper.go +++ b/federation/synchron/mainchain_keeper.go @@ -13,6 +13,7 @@ import ( "github.com/jinzhu/gorm" log "github.com/sirupsen/logrus" + vaporCfg "github.com/vapor/config" "github.com/vapor/errors" "github.com/vapor/federation/common" "github.com/vapor/federation/config" @@ -22,6 +23,8 @@ import ( "github.com/vapor/protocol/bc" ) +var fedProg = vaporCfg.FederationProgrom(vaporCfg.CommonConfig) + type mainchainKeeper struct { cfg *config.Chain db *gorm.DB @@ -87,7 +90,7 @@ func (m *mainchainKeeper) syncBlock() (bool, error) { "remote PreviousBlockHash": nextBlock.PreviousBlockHash.String(), "db block_hash": chain.BlockHash, }).Fatal("BlockHash mismatch") - return false, ErrInconsistentDB + return false, common.ErrInconsistentDB } if err := m.tryAttachBlock(chain, nextBlock, txStatus); err != nil { @@ -259,7 +262,7 @@ func (m *mainchainKeeper) processChainInfo(chain *orm.Chain, block *types.Block) } if res.RowsAffected != 1 { - return ErrInconsistentDB + return common.ErrInconsistentDB } return nil diff --git a/federation/synchron/sidechain_keeper.go b/federation/synchron/sidechain_keeper.go index 18ec269c..577a6e0d 100644 --- a/federation/synchron/sidechain_keeper.go +++ b/federation/synchron/sidechain_keeper.go @@ -85,7 +85,7 @@ func (s *sidechainKeeper) syncBlock() (bool, error) { "remote PreviousBlockHash": nextBlock.PreviousBlockHash.String(), "db block_hash": chain.BlockHash, }).Fatal("BlockHash mismatch") - return false, ErrInconsistentDB + return false, common.ErrInconsistentDB } if err := s.tryAttachBlock(chain, nextBlock, txStatus); err != nil { @@ -253,7 +253,7 @@ func (s *sidechainKeeper) processChainInfo(chain *orm.Chain, block *types.Block) } if res.RowsAffected != 1 { - return ErrInconsistentDB + return common.ErrInconsistentDB } return nil