"github.com/vapor/accesstoken"
"github.com/vapor/account"
"github.com/vapor/api"
+ "github.com/vapor/application/mov"
"github.com/vapor/asset"
"github.com/vapor/blockchain/pseudohsm"
cfg "github.com/vapor/config"
}
initCommonConfig(config)
- movDB := dbm.NewDB("mov", config.DBBackend, config.DBDir())
- mov, err := protocol.NewMOV(movDB, consensus.ActiveNetParams.MovStartPoint)
- if err != nil {
+ movCore := mov.NewMovCore(config.DBBackend, config.DBDir())
+ startPoint := consensus.ActiveNetParams.MovStartPoint
+ if startPoint.Height == 0 {
+ startPoint.Hash = cfg.GenesisBlock().Hash()
+ }
+ if err := movCore.InitChainStatus(startPoint.Height, &startPoint.Hash); err != nil {
log.Fatalf("Failed to create Mov protocol", err.Error())
}
// Get store
accessTokens := accesstoken.NewStore(tokenDB)
dispatcher := event.NewDispatcher()
- txPool := protocol.NewTxPool(store, []protocol.DustFilterer{mov}, dispatcher)
- chain, err := protocol.NewChain(store, txPool, []protocol.Protocoler{mov}, dispatcher)
+ txPool := protocol.NewTxPool(store, []protocol.DustFilterer{movCore}, dispatcher)
+ chain, err := protocol.NewChain(store, txPool, []protocol.Protocoler{movCore}, dispatcher)
if err != nil {
cmn.Exit(cmn.Fmt("Failed to create chain structure: %v", err))
}
notificationMgr: notificationMgr,
}
- node.cpuMiner = blockproposer.NewBlockProposer(chain, accounts, txPool, []blockproposer.Preprocessor{mov}, dispatcher)
+ node.cpuMiner = blockproposer.NewBlockProposer(chain, accounts, txPool, []blockproposer.Preprocessor{movCore}, dispatcher)
node.BaseService = *cmn.NewBaseService(nil, "Node", node)
return node
}
)
type Preprocessor interface {
- BeforeProposalBlock(capacity int) ([]*types.Tx, error)
+ BeforeProposalBlock(capacity int, nodeProgram []byte) ([]*types.Tx, error)
}
// BlockProposer propose several block in specified time range
break
}
- txs, err := p.BeforeProposalBlock(capacity)
+ txs, err := p.BeforeProposalBlock(capacity, []byte{0x51})
if err != nil {
log.WithFields(log.Fields{"module": logModule, "index": i, "error": err}).Error("failed on sub protocol txs package")
continue
}
for _, p := range c.subProtocols {
- if err := p.ValidateBlock(block); err != nil {
+ if err := p.ValidateBlock(block, bcBlock.TransactionStatus.GetVerifyStatus()); err != nil {
return errors.Wrap(err, "sub protocol save block")
}
}
+++ /dev/null
-package protocol
-
-import (
- "github.com/vapor/application/mov"
- "github.com/vapor/config"
- "github.com/vapor/consensus"
- dbm "github.com/vapor/database/leveldb"
- "github.com/vapor/errors"
- "github.com/vapor/protocol/bc"
- "github.com/vapor/protocol/bc/types"
-)
-
-const (
- protocolName = "MOV"
-)
-
-type movCore interface {
- ApplyBlock(block *types.Block) error
- BeforeProposalBlock(capacity int) ([]*types.Tx, error)
- ChainStatus() (uint64, *bc.Hash, error)
- DetachBlock(block *types.Block) error
- IsDust(tx *types.Tx) bool
- ValidateBlock(block *types.Block) error
- ValidateTxs(txs []*types.Tx) error
-}
-
-type MOV struct {
- core movCore
-}
-
-func NewMOV(db dbm.DB, startPoint consensus.Checkpoint) (*MOV, error) {
- if startPoint.Height == 0 {
- startPoint.Hash = config.GenesisBlock().Hash()
- }
-
- movCore, err := mov.NewMovCore(db, startPoint.Height, &startPoint.Hash)
- if err != nil {
- return nil, errors.Wrap(err, "failed on create mov core")
- }
-
- return &MOV{
- core: movCore,
- }, nil
-}
-
-func (m MOV) ApplyBlock(block *types.Block) error {
- return m.core.ApplyBlock(block)
-}
-
-func (m MOV) BeforeProposalBlock(capacity int) ([]*types.Tx, error) {
- return m.core.BeforeProposalBlock(capacity)
-}
-
-func (m MOV) ChainStatus() (uint64, *bc.Hash, error) {
- return m.core.ChainStatus()
-}
-
-func (m MOV) DetachBlock(block *types.Block) error {
- return m.core.DetachBlock(block)
-}
-
-func (m MOV) IsDust(tx *types.Tx) bool {
- return m.core.IsDust(tx)
-}
-
-func (m MOV) Name() string {
- return protocolName
-}
-
-func (m MOV) ValidateBlock(block *types.Block) error {
- return m.core.ValidateBlock(block)
-}
-
-func (m MOV) ValidateTxs(txs []*types.Tx) error {
- return m.core.ValidateTxs(txs)
-}
type Protocoler interface {
Name() string
ChainStatus() (uint64, *bc.Hash, error)
- ValidateBlock(block *types.Block) error
- ValidateTxs(txs []*types.Tx) error
+ ValidateBlock(block *types.Block, verifyResults []*bc.TxVerifyResult) error
+ ValidateTxs(txs []*types.Tx, verifyResults []*bc.TxVerifyResult) error
ApplyBlock(block *types.Block) error
DetachBlock(block *types.Block) error
}