forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nnary_slush.go
29 lines (20 loc) · 860 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
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package snowball
import (
"fmt"
"github.com/haowang0402/avalanchego/ids"
)
var _ NnarySlush = &nnarySlush{}
// 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
}
func (sl *nnarySlush) Initialize(choice ids.ID) { sl.preference = choice }
func (sl *nnarySlush) Preference() ids.ID { return sl.preference }
func (sl *nnarySlush) RecordSuccessfulPoll(choice ids.ID) { sl.preference = choice }
func (sl *nnarySlush) String() string { return fmt.Sprintf("SL(Preference = %s)", sl.preference) }