remove intsets usage (#3075)

This commit is contained in:
tersec 2021-11-10 02:18:52 +00:00 committed by GitHub
parent 3545d4d1e1
commit 59db4b4f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -11,7 +11,7 @@
import import
# Standard lib # Standard lib
std/[algorithm, intsets, math, sequtils, tables], std/[algorithm, math, sequtils, sets, tables],
# Status libraries # Status libraries
stew/[byteutils, endians2, bitops2], stew/[byteutils, endians2, bitops2],
chronicles, chronicles,
@ -93,21 +93,21 @@ func get_helper_indices*(
## to prove the chunks with the given generalized indices. Note that the ## to prove the chunks with the given generalized indices. Note that the
## decreasing order is chosen deliberately to ensure equivalence to the order ## decreasing order is chosen deliberately to ensure equivalence to the order
## of hashes in a regular single-item Merkle proof in the single-item case. ## of hashes in a regular single-item Merkle proof in the single-item case.
var all_helper_indices = initIntSet() var all_helper_indices = initHashSet[GeneralizedIndex]()
var all_path_indices = initIntSet()
for index in indices: for index in indices:
for idx in get_branch_indices(index): for idx in get_branch_indices(index):
all_helper_indices.incl idx.int all_helper_indices.incl idx
for index in indices:
for idx in get_path_indices(index): for idx in get_path_indices(index):
all_path_indices.incl idx.int all_helper_indices.excl idx
all_helper_indices.excl all_path_indices
result = newSeqOfCap[GeneralizedIndex](all_helper_indices.len) var res = newSeqOfCap[GeneralizedIndex](all_helper_indices.len)
for idx in all_helper_indices: for idx in all_helper_indices:
result.add idx.GeneralizedIndex res.add idx
result.sort(SortOrder.Descending) res.sort(SortOrder.Descending)
res
# https://github.com/ethereum/consensus-specs/blob/v1.1.2/ssz/merkle-proofs.md#merkle-multiproofs # https://github.com/ethereum/consensus-specs/blob/v1.1.5/ssz/merkle-proofs.md#merkle-multiproofs
func check_multiproof_acceptable*( func check_multiproof_acceptable*(
indices: openArray[GeneralizedIndex]): Result[void, string] = indices: openArray[GeneralizedIndex]): Result[void, string] =
# Check that proof verification won't allocate excessive amounts of memory. # Check that proof verification won't allocate excessive amounts of memory.