@@ -40,15 +40,18 @@ type Consensus interface {
40
40
Finalized () bool
41
41
}
42
42
43
- // NnarySnowball augments NnarySnowflake with a counter that tracks the total
44
- // number of positive responses from a network sample.
45
- type NnarySnowball interface { NnarySnowflake }
46
-
47
- // NnarySnowflake is a snowflake instance deciding between an unbounded number
48
- // of values. After performing a network sample of k nodes, if you have alpha
49
- // votes for one of the choices, you should vote for that choice. Otherwise, you
50
- // should reset.
51
- type NnarySnowflake interface {
43
+ // Factory produces Nnary and Unary decision instances
44
+ type Factory interface {
45
+ NewNnary (params Parameters , choice ids.ID ) Nnary
46
+ NewUnary (params Parameters ) Unary
47
+ }
48
+
49
+ // Nnary is a snow instance deciding between an unbounded number of values.
50
+ // The caller samples k nodes and then calls
51
+ // 1. RecordSuccessfulPoll if choice collects >= alphaConfidence votes
52
+ // 2. RecordPollPreference if choice collects >= alphaPreference votes
53
+ // 3. RecordUnsuccessfulPoll otherwise
54
+ type Nnary interface {
52
55
fmt.Stringer
53
56
54
57
// Adds a new possible choice
@@ -73,29 +76,12 @@ type NnarySnowflake interface {
73
76
Finalized () bool
74
77
}
75
78
76
- // NnarySlush is a slush instance deciding between an unbounded number of
77
- // values. After performing a network sample of k nodes, if you have alpha
78
- // votes for one of the choices, you should vote for that choice.
79
- type NnarySlush interface {
80
- fmt.Stringer
81
-
82
- // Returns the currently preferred choice to be finalized
83
- Preference () ids.ID
84
-
85
- // RecordSuccessfulPoll records a successful poll towards finalizing the
86
- // specified choice. Assumes the choice was previously added.
87
- RecordSuccessfulPoll (choice ids.ID )
88
- }
89
-
90
- // BinarySnowball augments BinarySnowflake with a counter that tracks the total
91
- // number of positive responses from a network sample.
92
- type BinarySnowball interface { BinarySnowflake }
93
-
94
- // BinarySnowflake is a snowball instance deciding between two values
95
- // After performing a network sample of k nodes, if you have alpha votes for
96
- // one of the choices, you should vote for that choice. Otherwise, you should
97
- // reset.
98
- type BinarySnowflake interface {
79
+ // Binary is a snow instance deciding between two values.
80
+ // The caller samples k nodes and then calls
81
+ // 1. RecordSuccessfulPoll if choice collects >= alphaConfidence votes
82
+ // 2. RecordPollPreference if choice collects >= alphaPreference votes
83
+ // 3. RecordUnsuccessfulPoll otherwise
84
+ type Binary interface {
99
85
fmt.Stringer
100
86
101
87
// Returns the currently preferred choice to be finalized
@@ -116,31 +102,20 @@ type BinarySnowflake interface {
116
102
Finalized () bool
117
103
}
118
104
119
- // BinarySlush is a slush instance deciding between two values. After performing
120
- // a network sample of k nodes, if you have alpha votes for one of the choices,
121
- // you should vote for that choice.
122
- type BinarySlush interface {
123
- fmt.Stringer
124
-
125
- // Returns the currently preferred choice to be finalized
126
- Preference () int
127
-
128
- // RecordSuccessfulPoll records a successful poll towards finalizing the
129
- // specified choice
130
- RecordSuccessfulPoll (choice int )
131
- }
132
-
133
- // UnarySnowball is a snowball instance deciding on one value. After performing
134
- // a network sample of k nodes, if you have alpha votes for the choice, you
135
- // should vote. Otherwise, you should reset.
136
- type UnarySnowball interface {
105
+ // Unary is a snow instance deciding on one value.
106
+ // The caller samples k nodes and then calls
107
+ // 1. RecordSuccessfulPoll if choice collects >= alphaConfidence votes
108
+ // 2. RecordPollPreference if choice collects >= alphaPreference votes
109
+ // 3. RecordUnsuccessfulPoll otherwise
110
+ type Unary interface {
137
111
fmt.Stringer
138
112
139
- // RecordSuccessfulPoll records a successful poll towards finalizing
113
+ // RecordSuccessfulPoll records a successful poll that reaches an alpha
114
+ // confidence threshold.
140
115
RecordSuccessfulPoll ()
141
116
142
- // RecordPollPreference records a poll that strengthens the preference but
143
- // did not contribute towards finalizing
117
+ // RecordPollPreference records a poll that receives an alpha preference
118
+ // threshold, but not an alpha confidence threshold.
144
119
RecordPollPreference ()
145
120
146
121
// RecordUnsuccessfulPoll resets the snowflake counter of this instance
@@ -151,31 +126,8 @@ type UnarySnowball interface {
151
126
152
127
// Returns a new binary snowball instance with the agreement parameters
153
128
// transferred. Takes in the new beta value and the original choice
154
- Extend (beta , originalPreference int ) BinarySnowball
155
-
156
- // Returns a new unary snowball instance with the same state
157
- Clone () UnarySnowball
158
- }
159
-
160
- // UnarySnowflake is a snowflake instance deciding on one value. After
161
- // performing a network sample of k nodes, if you have alpha votes for the
162
- // choice, you should vote. Otherwise, you should reset.
163
- type UnarySnowflake interface {
164
- fmt.Stringer
165
-
166
- // RecordSuccessfulPoll records a successful poll towards finalizing
167
- RecordSuccessfulPoll ()
168
-
169
- // RecordUnsuccessfulPoll resets the snowflake counter of this instance
170
- RecordUnsuccessfulPoll ()
171
-
172
- // Return whether a choice has been finalized
173
- Finalized () bool
174
-
175
- // Returns a new binary snowball instance with the agreement parameters
176
- // transferred. Takes in the new beta value and the original choice
177
- Extend (beta , originalPreference int ) BinarySnowflake
129
+ Extend (beta , originalPreference int ) Binary
178
130
179
131
// Returns a new unary snowflake instance with the same state
180
- Clone () UnarySnowflake
132
+ Clone () Unary
181
133
}
0 commit comments