-
Notifications
You must be signed in to change notification settings - Fork 670
/
options.go
95 lines (77 loc) · 2.12 KB
/
options.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package executor
import (
"fmt"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/vms/platformvm/block"
)
var _ block.Visitor = (*verifier)(nil)
// options supports build new option blocks
type options struct {
// outputs populated by this struct's methods:
commitBlock block.Block
abortBlock block.Block
}
func (*options) BanffAbortBlock(*block.BanffAbortBlock) error {
return snowman.ErrNotOracle
}
func (*options) BanffCommitBlock(*block.BanffCommitBlock) error {
return snowman.ErrNotOracle
}
func (o *options) BanffProposalBlock(b *block.BanffProposalBlock) error {
timestamp := b.Timestamp()
blkID := b.ID()
nextHeight := b.Height() + 1
var err error
o.commitBlock, err = block.NewBanffCommitBlock(timestamp, blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create commit block: %w",
err,
)
}
o.abortBlock, err = block.NewBanffAbortBlock(timestamp, blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create abort block: %w",
err,
)
}
return nil
}
func (*options) BanffStandardBlock(*block.BanffStandardBlock) error {
return snowman.ErrNotOracle
}
func (*options) ApricotAbortBlock(*block.ApricotAbortBlock) error {
return snowman.ErrNotOracle
}
func (*options) ApricotCommitBlock(*block.ApricotCommitBlock) error {
return snowman.ErrNotOracle
}
func (o *options) ApricotProposalBlock(b *block.ApricotProposalBlock) error {
blkID := b.ID()
nextHeight := b.Height() + 1
var err error
o.commitBlock, err = block.NewApricotCommitBlock(blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create commit block: %w",
err,
)
}
o.abortBlock, err = block.NewApricotAbortBlock(blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create abort block: %w",
err,
)
}
return nil
}
func (*options) ApricotStandardBlock(*block.ApricotStandardBlock) error {
return snowman.ErrNotOracle
}
func (*options) ApricotAtomicBlock(*block.ApricotAtomicBlock) error {
return snowman.ErrNotOracle
}