"fmt"
"time"
-// "github.com/blockchain/crypto/ed25519"
+ // "github.com/blockchain/crypto/ed25519"
"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"
-// "github.com/blockchain/protocol/vm/vmutil"
+ // "github.com/blockchain/protocol/vm/vmutil"
)
// maxBlockTxs limits the number of transactions
Height: prev.Height + 1,
PreviousBlockHash: prev.Hash(),
TimestampMS: timestampMS,
- BlockCommitment: legacy.BlockCommitment{
- ConsensusProgram: prev.ConsensusProgram,
- },
+ BlockCommitment: legacy.BlockCommitment{},
},
}
if err != nil {
return errors.Sub(ErrBadBlock, err)
}
- if block.Height > 1 {
- err = validation.ValidateBlockSig(blockEnts, prevEnts.NextConsensusProgram)
- }
return errors.Sub(ErrBadBlock, err)
}
return errors.Sub(ErrBadBlock, err)
}
-func NewInitialBlock(/*pubkeys []ed25519.PublicKey, nSigs int, timestamp time.Time*/) (*legacy.Block, error) {
+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.
-
-/*
- script, err := vmutil.BlockMultiSigProgram(pubkeys, nSigs)
- if err != nil {
- return nil, err
- }
-
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{
+ TimestampMS: bc.Millis(timestamp),
+ BlockCommitment: legacy.BlockCommitment{
TransactionsMerkleRoot: root,
- ConsensusProgram: script,
- },*/
+ },
},
}
return b, nil
BlockCommitment: legacy.BlockCommitment{
TransactionsMerkleRoot: wantTxRoot,
AssetsMerkleRoot: wantAssetsRoot,
- ConsensusProgram: b1.ConsensusProgram,
},
},
Transactions: txs,
}
func TestValidateBlockForSig(t *testing.T) {
- initialBlock, err := NewInitialBlock(testutil.TestPubs, 1, time.Now())
+ initialBlock, err := NewInitialBlock(time.Now())
if err != nil {
t.Fatal("unexpected error ", err)
}
var err error
- b1, err = NewInitialBlock(nil, 0, ts)
+ b1, err = NewInitialBlock(ts)
if err != nil {
testutil.FatalErr(tb, err)
}
func TestRecoverSnapshotNoAdditionalBlocks(t *testing.T) {
store := memstore.New()
- b, err := NewInitialBlock(nil, 0, time.Now().Add(-time.Minute))
+ b, err := NewInitialBlock(time.Now().Add(-time.Minute))
if err != nil {
testutil.FatalErr(t, err)
}
BlockCommitment: legacy.BlockCommitment{
TransactionsMerkleRoot: root,
AssetsMerkleRoot: snapshot.Tree.RootHash(),
- ConsensusProgram: block.ConsensusProgram,
},
},
}