}
initCommonConfig(config)
-
- mov := protocol.NewMOV()
+ movDB := dbm.NewDB("mov", config.DBBackend, config.DBDir())
+ mov, err := protocol.NewMOV(movDB, consensus.ActiveNetParams.MovStartPoint)
+ if err != nil {
+ log.Fatalf("Failed to create Mov protocol", err.Error())
+ }
// Get store
if config.DBBackend != "memdb" && config.DBBackend != "leveldb" {
cmn.Exit(cmn.Fmt("Param db_backend [%v] is invalid, use leveldb or memdb", config.DBBackend))
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"
)
protocolName = "MOV"
)
-type matchEnginer interface {
+type movCore interface {
ApplyBlock(block *types.Block) error
BeforeProposalBlock(capacity int) ([]*types.Tx, error)
ChainStatus() (uint64, *bc.Hash, error)
}
type MOV struct {
- engine matchEnginer
+ core movCore
}
-func NewMOV() *MOV {
- return &MOV{}
+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.engine.ApplyBlock(block)
+ return m.core.ApplyBlock(block)
}
func (m MOV) BeforeProposalBlock(capacity int) ([]*types.Tx, error) {
- return m.engine.BeforeProposalBlock(capacity)
+ return m.core.BeforeProposalBlock(capacity)
}
func (m MOV) ChainStatus() (uint64, *bc.Hash, error) {
- return m.engine.ChainStatus()
+ return m.core.ChainStatus()
}
func (m MOV) DetachBlock(block *types.Block) error {
- return m.engine.DetachBlock(block)
+ return m.core.DetachBlock(block)
}
func (m MOV) IsDust(tx *types.Tx) bool {
- return m.engine.IsDust(tx)
+ return m.core.IsDust(tx)
}
func (m MOV) Name() string {
}
func (m MOV) ValidateBlock(block *types.Block) error {
- return m.engine.ValidateBlock(block)
+ return m.core.ValidateBlock(block)
}
func (m MOV) ValidateTxs(txs []*types.Tx) error {
- return m.engine.ValidateTxs(txs)
+ return m.core.ValidateTxs(txs)
}