-
Notifications
You must be signed in to change notification settings - Fork 0
/
nnary_slush.go
30 lines (22 loc) · 973 Bytes
/
nnary_slush.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
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package snowball
import (
"fmt"
"github.com/ava-labs/avalanchego/ids"
)
// nnarySlush is the implementation of a slush instance with an unbounded number
// of choices
type nnarySlush struct {
// preference is the choice that last had a successful poll. Unless there
// hasn't been a successful poll, in which case it is the initially provided
// choice.
preference ids.ID
}
// Initialize implements the NnarySlush interface
func (sl *nnarySlush) Initialize(choice ids.ID) { sl.preference = choice }
// Preference implements the NnarySlush interface
func (sl *nnarySlush) Preference() ids.ID { return sl.preference }
// RecordSuccessfulPoll implements the NnarySlush interface
func (sl *nnarySlush) RecordSuccessfulPoll(choice ids.ID) { sl.preference = choice }
func (sl *nnarySlush) String() string { return fmt.Sprintf("SL(Preference = %s)", sl.preference) }