Select smallest coins for contracts #1519
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From previous PR #1289;
I've reworked this a bit and made it a lot smaller and taken into account your request @denravonska for .sort() and .random.
We still have to use a comparator as std::sort cannot compare COutput.
The reason the std::random_shuffle works with it because its just randomly shifting the contents.
This is more simple approach as I can tell and tested on testnet. If its a contract it will use the smallest for sure as even the subset function will favor the smallest to larger since its already sorted and not randomly shuffled. this is minimal impact in the code area with the desired effect.
Desired effect of this with regards to votes, polls and beacons is to make sure we use the smallest utxos when possible and not end up using a biggest utxo that a user has been staking with and delaying that staking for the 16 hour maturing window.