-
Notifications
You must be signed in to change notification settings - Fork 646
/
acceptor.go
38 lines (30 loc) · 891 Bytes
/
acceptor.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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package snowstorm
import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/events"
"github.com/ava-labs/avalanchego/utils/wrappers"
)
var _ events.Blockable = &acceptor{}
type acceptor struct {
g *Directed
errs *wrappers.Errs
deps ids.Set
rejected bool
txID ids.ID
}
func (a *acceptor) Dependencies() ids.Set { return a.deps }
func (a *acceptor) Fulfill(id ids.ID) {
a.deps.Remove(id)
a.Update()
}
func (a *acceptor) Abandon(id ids.ID) { a.rejected = true }
func (a *acceptor) Update() {
// If I was rejected or I am still waiting on dependencies to finish or an
// error has occurred, I shouldn't do anything.
if a.rejected || a.deps.Len() != 0 || a.errs.Errored() {
return
}
a.errs.Add(a.g.accept(a.txID))
}