forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
options.go
95 lines (77 loc) · 2.14 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/MetalBlockchain/metalgo/snow/consensus/snowman"
"github.com/MetalBlockchain/metalgo/vms/platformvm/blocks"
)
var _ blocks.Visitor = (*verifier)(nil)
// options supports build new option blocks
type options struct {
// outputs populated by this struct's methods:
commitBlock blocks.Block
abortBlock blocks.Block
}
func (*options) BanffAbortBlock(*blocks.BanffAbortBlock) error {
return snowman.ErrNotOracle
}
func (*options) BanffCommitBlock(*blocks.BanffCommitBlock) error {
return snowman.ErrNotOracle
}
func (o *options) BanffProposalBlock(b *blocks.BanffProposalBlock) error {
timestamp := b.Timestamp()
blkID := b.ID()
nextHeight := b.Height() + 1
var err error
o.commitBlock, err = blocks.NewBanffCommitBlock(timestamp, blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create commit block: %w",
err,
)
}
o.abortBlock, err = blocks.NewBanffAbortBlock(timestamp, blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create abort block: %w",
err,
)
}
return nil
}
func (*options) BanffStandardBlock(*blocks.BanffStandardBlock) error {
return snowman.ErrNotOracle
}
func (*options) ApricotAbortBlock(*blocks.ApricotAbortBlock) error {
return snowman.ErrNotOracle
}
func (*options) ApricotCommitBlock(*blocks.ApricotCommitBlock) error {
return snowman.ErrNotOracle
}
func (o *options) ApricotProposalBlock(b *blocks.ApricotProposalBlock) error {
blkID := b.ID()
nextHeight := b.Height() + 1
var err error
o.commitBlock, err = blocks.NewApricotCommitBlock(blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create commit block: %w",
err,
)
}
o.abortBlock, err = blocks.NewApricotAbortBlock(blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create abort block: %w",
err,
)
}
return nil
}
func (*options) ApricotStandardBlock(*blocks.ApricotStandardBlock) error {
return snowman.ErrNotOracle
}
func (*options) ApricotAtomicBlock(*blocks.ApricotAtomicBlock) error {
return snowman.ErrNotOracle
}