forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
rejector.go
41 lines (32 loc) · 940 Bytes
/
rejector.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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package snowstorm
import (
"context"
"github.com/MetalBlockchain/metalgo/ids"
"github.com/MetalBlockchain/metalgo/snow/events"
"github.com/MetalBlockchain/metalgo/utils/set"
"github.com/MetalBlockchain/metalgo/utils/wrappers"
)
var _ events.Blockable = (*rejector)(nil)
type rejector struct {
g *Directed
errs *wrappers.Errs
deps set.Set[ids.ID]
rejected bool // true if the tx has been rejected
txID ids.ID
}
func (r *rejector) Dependencies() set.Set[ids.ID] {
return r.deps
}
func (r *rejector) Fulfill(ctx context.Context, _ ids.ID) {
if r.rejected || r.errs.Errored() {
return
}
r.rejected = true
asSet := set.NewSet[ids.ID](1)
asSet.Add(r.txID)
r.errs.Add(r.g.reject(ctx, asSet))
}
func (*rejector) Abandon(context.Context, ids.ID) {}
func (*rejector) Update(context.Context) {}