OSDN Git Service

clean up
authorHAOYUatHZ <haoyu@protonmail.com>
Fri, 14 Jun 2019 00:17:45 +0000 (08:17 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Fri, 14 Jun 2019 00:17:45 +0000 (08:17 +0800)
federation/common/const.go
federation/synchron/common.go [deleted file]
federation/synchron/mainchain_keeper.go
federation/synchron/sidechain_keeper.go

index e843f9e..0a91d33 100644 (file)
@@ -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 (file)
index 0bfc236..0000000
+++ /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")
-)
index f0a7fd8..13a315f 100644 (file)
@@ -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
index 18ec269..577a6e0 100644 (file)
@@ -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