OSDN Git Service

Merge remote-tracking branch 'origin/master' into sub_protocol
[bytom/vapor.git] / protocol / mov.go
1 package protocol
2
3 import (
4         "github.com/vapor/protocol/bc"
5         "github.com/vapor/protocol/bc/types"
6 )
7
8 const (
9         protocolName = "MOV"
10 )
11
12 type matchEnginer interface {
13         ApplyBlock(block *types.Block) error
14         BeforeProposalBlock(capacity int) ([]*types.Tx, error)
15         ChainStatus() (uint64, *bc.Hash, error)
16         DetachBlock(block *types.Block) error
17         IsDust(tx *types.Tx) bool
18         ValidateBlock(block *types.Block) error
19         ValidateTxs(txs []*types.Tx) error
20 }
21
22 type MOV struct {
23         engine matchEnginer
24 }
25
26 func NewMOV() *MOV {
27         return &MOV{}
28 }
29
30 func (m MOV) ApplyBlock(block *types.Block) error {
31         return m.engine.ApplyBlock(block)
32 }
33
34 func (m MOV) BeforeProposalBlock(capacity int) ([]*types.Tx, error) {
35         return m.engine.BeforeProposalBlock(capacity)
36 }
37
38 func (m MOV) ChainStatus() (uint64, *bc.Hash, error) {
39         return m.engine.ChainStatus()
40 }
41
42 func (m MOV) DetachBlock(block *types.Block) error {
43         return m.engine.DetachBlock(block)
44 }
45
46 func (m MOV) IsDust(tx *types.Tx) bool {
47         return m.engine.IsDust(tx)
48 }
49
50 func (m MOV) Name() string {
51         return protocolName
52 }
53
54 func (m MOV) ValidateBlock(block *types.Block) error {
55         return m.engine.ValidateBlock(block)
56 }
57
58 func (m MOV) ValidateTxs(txs []*types.Tx) error {
59         return m.engine.ValidateTxs(txs)
60 }