iotaledger / iota-sdk

The IOTA SDK provides developers with a seamless experience to develop on IOTA by providing account abstractions and clients to interact with node APIs.
Apache License 2.0
54 stars 39 forks source link

Better input ordering #2175

Closed DaughterOfMars closed 3 months ago

DaughterOfMars commented 3 months ago

Description of change

Previously, we sorted the inputs when the builder is finished (and in the mana requirement) but this was unnecessary as we can sort them when selecting instead and just maintain the sorted order.

UPDATE: After some re-evaluation, the above approach is not possible because inputs may be added that have requirements that have not yet been selected, but will be later. This would then need basically the same re-sorting logic. Instead, I implemented a custom collection which holds useful information for ordering the inputs and handles the actual order in the iterator implementations. This does require some additional memory overhead per reference iterator call (but not for consuming iteration): An additional VecDeque and BTreeMap are allocated, plus one VecDeque per non-ed25519 address.