OSDN Git Service

test: add read/write test for cross-chain input/output (#70)
[bytom/vapor.git] / protocol / protocol.go
index ff61e18..9fb2b3d 100644 (file)
@@ -6,8 +6,6 @@ import (
        log "github.com/sirupsen/logrus"
 
        "github.com/vapor/config"
-       engine "github.com/vapor/consensus/consensus"
-       "github.com/vapor/errors"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
        "github.com/vapor/protocol/state"
@@ -23,11 +21,8 @@ type Chain struct {
        store          Store
        processBlockCh chan *processBlockMsg
 
-       cond       sync.Cond
-       bestNode   *state.BlockNode
-       Authoritys map[string]string
-       position   uint64
-       engine     engine.Engine
+       cond     sync.Cond
+       bestNode *state.BlockNode
 }
 
 // NewChain returns a new Chain using store as the underlying storage.
@@ -59,18 +54,6 @@ func NewChain(store Store, txPool *TxPool) (*Chain, error) {
        return c, nil
 }
 
-func (c *Chain) SetAuthoritys(authoritys map[string]string) {
-       c.Authoritys = authoritys
-}
-
-func (c *Chain) SetPosition(position uint64) {
-       c.position = position
-}
-
-func (c *Chain) SetConsensusEngine(engine engine.Engine) {
-       c.engine = engine
-}
-
 func (c *Chain) initChainStatus() error {
        genesisBlock := config.GenesisBlock()
        txStatus := bc.NewTransactionStatus()
@@ -122,24 +105,6 @@ func (c *Chain) InMainChain(hash bc.Hash) bool {
        return c.index.InMainchain(hash)
 }
 
-// CalcNextSeed return the seed for the given block
-func (c *Chain) CalcNextSeed(preBlock *bc.Hash) (*bc.Hash, error) {
-       node := c.index.GetNode(preBlock)
-       if node == nil {
-               return nil, errors.New("can't find preblock in the blockindex")
-       }
-       return node.CalcNextSeed(), nil
-}
-
-// CalcNextBits return the seed for the given block
-func (c *Chain) CalcNextBits(preBlock *bc.Hash) (uint64, error) {
-       node := c.index.GetNode(preBlock)
-       if node == nil {
-               return 0, errors.New("can't find preblock in the blockindex")
-       }
-       return node.CalcNextBits(), nil
-}
-
 // This function must be called with mu lock in above level
 func (c *Chain) setState(node *state.BlockNode, view *state.UtxoViewpoint) error {
        if err := c.store.SaveChainStatus(node, view); err != nil {
@@ -152,7 +117,7 @@ func (c *Chain) setState(node *state.BlockNode, view *state.UtxoViewpoint) error
        c.index.SetMainChain(node)
        c.bestNode = node
 
-       log.WithFields(log.Fields{"height": c.bestNode.Height, "hash": c.bestNode.Hash.String()}).Debug("chain best status has been update")
+       log.WithFields(log.Fields{"module": logModule, "height": c.bestNode.Height, "hash": c.bestNode.Hash.String()}).Debug("chain best status has been update")
        c.cond.Broadcast()
        return nil
 }