-
Notifications
You must be signed in to change notification settings - Fork 2
/
vm.go
62 lines (53 loc) · 1.92 KB
/
vm.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
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package vertex
import (
"context"
"github.com/DioneProtocol/odysseygo/ids"
"github.com/DioneProtocol/odysseygo/snow/consensus/snowstorm"
"github.com/DioneProtocol/odysseygo/snow/engine/common"
"github.com/DioneProtocol/odysseygo/snow/engine/snowman/block"
)
type LinearizableVMWithEngine interface {
DAGVM
// Linearize is called after [Initialize] and after the DAG has been
// finalized. After Linearize is called:
//
// - PendingTxs will never be called again
// - GetTx will never be called again
// - ParseTx may still be called
// - All the block based functions of the [block.ChainVM] must work as
// expected.
//
// Linearize is part of the VM initialization, and will be called at most
// once per VM instantiation. This means that Linearize should be called
// every time the chain restarts after the DAG has finalized.
Linearize(
ctx context.Context,
stopVertexID ids.ID,
toEngine chan<- common.Message,
) error
}
type LinearizableVM interface {
DAGVM
// Linearize is called after [Initialize] and after the DAG has been
// finalized. After Linearize is called:
//
// - PendingTxs will never be called again
// - GetTx will never be called again
// - ParseTx may still be called
// - All the block based functions of the [block.ChainVM] must work as
// expected.
//
// Linearize is part of the VM initialization, and will be called at most
// once per VM instantiation. This means that Linearize should be called
// every time the chain restarts after the DAG has finalized.
Linearize(ctx context.Context, stopVertexID ids.ID) error
}
// DAGVM defines the minimum functionality that an avalanche VM must
// implement
type DAGVM interface {
block.ChainVM
// Convert a stream of bytes to a transaction or return an error
ParseTx(ctx context.Context, txBytes []byte) (snowstorm.Tx, error)
}