Skip to content

Commit e5c5c14

Browse files
committed
undo
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
1 parent 7bdefd4 commit e5c5c14

File tree

1 file changed

+84
-82
lines changed

1 file changed

+84
-82
lines changed

snow/consensus/snowball/tree.go

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ func (u *unaryNode) DecidedPrefix() int {
175175
return u.decidedPrefix
176176
}
177177

178+
//nolint:gci,gofmt,gofumpt // this comment is formatted as intended
179+
//
178180
// This is by far the most complicated function in this algorithm.
179181
// The intuition is that this instance represents a series of consecutive unary
180182
// snowball instances, and this function's purpose is convert one of these unary
@@ -186,23 +188,23 @@ func (u *unaryNode) DecidedPrefix() int {
186188
//
187189
// For example, attempting to insert the value "00001" in this node:
188190
//
189-
// +-------------------+ <-- This node will not be split
190-
// | |
191-
// | 0 0 0 |
192-
// | |
193-
// +-------------------+ <-- Pass the add to the child
194-
// ^
195-
// |
191+
// +-------------------+ <-- This node will not be split
192+
// | |
193+
// | 0 0 0 |
194+
// | |
195+
// +-------------------+ <-- Pass the add to the child
196+
// ^
197+
// |
196198
//
197199
// Results in:
198200
//
199-
// +-------------------+
200-
// | |
201-
// | 0 0 0 |
202-
// | |
203-
// +-------------------+ <-- With the modified child
204-
// ^
205-
// |
201+
// +-------------------+
202+
// | |
203+
// | 0 0 0 |
204+
// | |
205+
// +-------------------+ <-- With the modified child
206+
// ^
207+
// |
206208
//
207209
// 2. This instance represents a series of only one unary instance and it must
208210
// be split.
@@ -213,19 +215,19 @@ func (u *unaryNode) DecidedPrefix() int {
213215
//
214216
// For example, attempting to insert the value "1" in this tree:
215217
//
216-
// +-------------------+
217-
// | |
218-
// | 0 |
219-
// | |
220-
// +-------------------+
218+
// +-------------------+
219+
// | |
220+
// | 0 |
221+
// | |
222+
// +-------------------+
221223
//
222224
// Results in:
223225
//
224-
// +-------------------+
225-
// | | |
226-
// | 0 | 1 |
227-
// | | |
228-
// +-------------------+
226+
// +-------------------+
227+
// | | |
228+
// | 0 | 1 |
229+
// | | |
230+
// +-------------------+
229231
//
230232
// 3. This instance must be split on the first bit
231233
//
@@ -235,26 +237,26 @@ func (u *unaryNode) DecidedPrefix() int {
235237
//
236238
// For example, attempting to insert the value "10" in this tree:
237239
//
238-
// +-------------------+
239-
// | |
240-
// | 0 0 |
241-
// | |
242-
// +-------------------+
240+
// +-------------------+
241+
// | |
242+
// | 0 0 |
243+
// | |
244+
// +-------------------+
243245
//
244246
// Results in:
245247
//
246-
// +-------------------+
247-
// | | |
248-
// | 0 | 1 |
249-
// | | |
250-
// +-------------------+
251-
// ^ ^
252-
// / \
253-
// +-------------------+ +-------------------+
254-
// | | | |
255-
// | 0 | | 0 |
256-
// | | | |
257-
// +-------------------+ +-------------------+
248+
// +-------------------+
249+
// | | |
250+
// | 0 | 1 |
251+
// | | |
252+
// +-------------------+
253+
// ^ ^
254+
// / \
255+
// +-------------------+ +-------------------+
256+
// | | | |
257+
// | 0 | | 0 |
258+
// | | | |
259+
// +-------------------+ +-------------------+
258260
//
259261
// 4. This instance must be split on the last bit
260262
//
@@ -265,26 +267,26 @@ func (u *unaryNode) DecidedPrefix() int {
265267
//
266268
// For example, attempting to insert the value "01" in this tree:
267269
//
268-
// +-------------------+
269-
// | |
270-
// | 0 0 |
271-
// | |
272-
// +-------------------+
270+
// +-------------------+
271+
// | |
272+
// | 0 0 |
273+
// | |
274+
// +-------------------+
273275
//
274276
// Results in:
275277
//
276-
// +-------------------+
277-
// | |
278-
// | 0 |
279-
// | |
280-
// +-------------------+
281-
// ^
282-
// |
283-
// +-------------------+
284-
// | | |
285-
// | 0 | 1 |
286-
// | | |
287-
// +-------------------+
278+
// +-------------------+
279+
// | |
280+
// | 0 |
281+
// | |
282+
// +-------------------+
283+
// ^
284+
// |
285+
// +-------------------+
286+
// | | |
287+
// | 0 | 1 |
288+
// | | |
289+
// +-------------------+
288290
//
289291
// 5. This instance must be split on an interior bit
290292
//
@@ -296,33 +298,33 @@ func (u *unaryNode) DecidedPrefix() int {
296298
//
297299
// For example, attempting to insert the value "010" in this tree:
298300
//
299-
// +-------------------+
300-
// | |
301-
// | 0 0 0 |
302-
// | |
303-
// +-------------------+
301+
// +-------------------+
302+
// | |
303+
// | 0 0 0 |
304+
// | |
305+
// +-------------------+
304306
//
305307
// Results in:
306308
//
307-
// +-------------------+
308-
// | |
309-
// | 0 |
310-
// | |
311-
// +-------------------+
312-
// ^
313-
// |
314-
// +-------------------+
315-
// | | |
316-
// | 0 | 1 |
317-
// | | |
318-
// +-------------------+
319-
// ^ ^
320-
// / \
321-
// +-------------------+ +-------------------+
322-
// | | | |
323-
// | 0 | | 0 |
324-
// | | | |
325-
// +-------------------+ +-------------------+
309+
// +-------------------+
310+
// | |
311+
// | 0 |
312+
// | |
313+
// +-------------------+
314+
// ^
315+
// |
316+
// +-------------------+
317+
// | | |
318+
// | 0 | 1 |
319+
// | | |
320+
// +-------------------+
321+
// ^ ^
322+
// / \
323+
// +-------------------+ +-------------------+
324+
// | | | |
325+
// | 0 | | 0 |
326+
// | | | |
327+
// +-------------------+ +-------------------+
326328
func (u *unaryNode) Add(newChoice ids.ID) node {
327329
if u.Finalized() {
328330
return u // Only happens if the tree is finalized, or it's a leaf node

0 commit comments

Comments
 (0)