OSDN Git Service

delete the unused code
authorpaladz <453256728@qq.com>
Sat, 23 Sep 2017 06:22:05 +0000 (14:22 +0800)
committerpaladz <453256728@qq.com>
Sat, 23 Sep 2017 06:22:05 +0000 (14:22 +0800)
protocol/block.go
protocol/prottest/block.go

index ac46aed..172c8e6 100644 (file)
@@ -6,7 +6,6 @@ import (
 
        "github.com/bytom/errors"
        "github.com/bytom/log"
-       "github.com/bytom/protocol/bc"
        "github.com/bytom/protocol/bc/legacy"
        "github.com/bytom/protocol/state"
        "github.com/bytom/protocol/validation"
@@ -144,26 +143,3 @@ func (c *Chain) setHeight(h uint64) {
        c.state.height = h
        c.state.cond.Broadcast()
 }
-
-func NewInitialBlock(timestamp time.Time) (*legacy.Block, error) {
-       // TODO(kr): move this into a lower-level package (e.g. chain/protocol/bc)
-       // so that other packages (e.g. chain/protocol/validation) unit tests can
-       // call this function.
-       root, err := bc.MerkleRoot(nil) // calculate the zero value of the tx merkle root
-       if err != nil {
-               return nil, errors.Wrap(err, "calculating zero value of tx merkle root")
-       }
-
-       b := &legacy.Block{
-               BlockHeader: legacy.BlockHeader{
-                       Version:     1,
-                       Height:      1,
-                       TimestampMS: bc.Millis(timestamp),
-                       BlockCommitment: legacy.BlockCommitment{
-                               TransactionsMerkleRoot: root,
-                       },
-               },
-               Transactions: []*legacy.Tx{},
-       }
-       return b, nil
-}
index 4c1ae81..4efbe2e 100644 (file)
@@ -1,16 +1,13 @@
 package prottest
 
 import (
-       "context"
        "sync"
        "testing"
-       "time"
 
        "github.com/bytom/crypto/ed25519"
        "github.com/bytom/protocol"
        "github.com/bytom/protocol/bc"
        "github.com/bytom/protocol/bc/legacy"
-       "github.com/bytom/protocol/prottest/memstore"
        "github.com/bytom/protocol/state"
        "github.com/bytom/testutil"
 )
@@ -58,42 +55,6 @@ type config struct {
        quorum       int
 }
 
-// NewChain makes a new Chain. By default it uses a memstore for
-// storage and creates an initial block using a 0/0 multisig program.
-// It commits the initial block before returning the Chain.
-//
-// Its defaults may be overridden by providing Options.
-func NewChain(tb testing.TB, opts ...Option) *protocol.Chain {
-       conf := config{store: memstore.New(), initialState: state.Empty()}
-       for _, opt := range opts {
-               opt(tb, &conf)
-       }
-
-       ctx := context.Background()
-       b1, err := protocol.NewInitialBlock(time.Now())
-       if err != nil {
-               testutil.FatalErr(tb, err)
-       }
-       c, err := protocol.NewChain(ctx, b1.Hash(), conf.store, nil)
-       if err != nil {
-               testutil.FatalErr(tb, err)
-       }
-       c.MaxIssuanceWindow = 48 * time.Hour // TODO(tessr): consider adding MaxIssuanceWindow to NewChain
-
-       err = c.CommitAppliedBlock(ctx, b1, conf.initialState)
-       if err != nil {
-               testutil.FatalErr(tb, err)
-       }
-
-       // save block-signing keys in global state
-       mutex.Lock()
-       blockPubkeys[c] = conf.pubkeys
-       blockPrivkeys[c] = conf.privkeys
-       mutex.Unlock()
-
-       return c
-}
-
 // Initial returns the provided Chain's initial block.
 func Initial(tb testing.TB, c *protocol.Chain) *legacy.Block {
        b1, err := c.GetBlock(1)