parity-zcash icon indicating copy to clipboard operation
parity-zcash copied to clipboard

Refactor node ordering logic

Open hdevalence opened this issue 5 years ago • 2 comments

The logic here could be simplified using a tuple comparison. Also it's not required to duplicate logic between the PartialOrd and Ord impls, Ord is a marker trait. https://github.com/ZcashFoundation/zebra/blob/master/zebra-p2p/src/util/node_table.rs#L54-L92

hdevalence avatar Jul 19 '19 20:07 hdevalence

note also: because the NodeTable maintains BTreeSets for by_score, by_time, but the custom-ordering-tuple-newtypes don't hold borrows, all of the node data is held in triplicate

hdevalence avatar Jul 19 '19 20:07 hdevalence

aha, we may not be able just to simplify the comparison functions, because the code that maintains the data in triplicate stops working if we relax requirements on the sort-by-x functions (e.g., so that two nodes with equal time are equal when sorted by time).

hdevalence avatar Jul 19 '19 22:07 hdevalence