-
Notifications
You must be signed in to change notification settings - Fork 1
/
engine.go
75 lines (62 loc) · 1.98 KB
/
engine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avalanche
import (
"context"
"errors"
"github.com/DioneProtocol/odysseygo/snow"
"github.com/DioneProtocol/odysseygo/snow/engine/common"
)
var (
_ common.Engine = (*engine)(nil)
errUnexpectedStart = errors.New("unexpectedly started engine")
)
type engine struct {
common.AllGetsServer
// list of NoOpsHandler for messages dropped by engine
common.StateSummaryFrontierHandler
common.AcceptedStateSummaryHandler
common.AcceptedFrontierHandler
common.AcceptedHandler
common.AncestorsHandler
common.PutHandler
common.QueryHandler
common.ChitsHandler
common.AppHandler
common.InternalHandler
ctx *snow.ConsensusContext
vm common.VM
}
func New(
ctx *snow.ConsensusContext,
gets common.AllGetsServer,
vm common.VM,
) common.Engine {
return &engine{
AllGetsServer: gets,
StateSummaryFrontierHandler: common.NewNoOpStateSummaryFrontierHandler(ctx.Log),
AcceptedStateSummaryHandler: common.NewNoOpAcceptedStateSummaryHandler(ctx.Log),
AcceptedFrontierHandler: common.NewNoOpAcceptedFrontierHandler(ctx.Log),
AcceptedHandler: common.NewNoOpAcceptedHandler(ctx.Log),
AncestorsHandler: common.NewNoOpAncestorsHandler(ctx.Log),
PutHandler: common.NewNoOpPutHandler(ctx.Log),
QueryHandler: common.NewNoOpQueryHandler(ctx.Log),
ChitsHandler: common.NewNoOpChitsHandler(ctx.Log),
AppHandler: common.NewNoOpAppHandler(ctx.Log),
InternalHandler: common.NewNoOpInternalHandler(ctx.Log),
ctx: ctx,
vm: vm,
}
}
func (*engine) Start(context.Context, uint32) error {
return errUnexpectedStart
}
func (e *engine) Context() *snow.ConsensusContext {
return e.ctx
}
func (e *engine) GetVM() common.VM {
return e.vm
}
func (*engine) HealthCheck(context.Context) (interface{}, error) {
return nil, nil
}