Early exits while finding spendable outputs
This commit is contained in:
parent
fee9bfd3af
commit
1261b61fff
|
@ -28,6 +28,10 @@ func (u UTXOSet) FindSpendableOutputs(pubkeyHash []byte, amount int) (int, map[s
|
||||||
txID := hex.EncodeToString(k)
|
txID := hex.EncodeToString(k)
|
||||||
outs := DeserializeOutputs(v)
|
outs := DeserializeOutputs(v)
|
||||||
|
|
||||||
|
if accumulated >= amount {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
for outIdx, out := range outs.Outputs {
|
for outIdx, out := range outs.Outputs {
|
||||||
if out.IsLockedWithKey(pubkeyHash) && accumulated < amount {
|
if out.IsLockedWithKey(pubkeyHash) && accumulated < amount {
|
||||||
accumulated += out.Value
|
accumulated += out.Value
|
||||||
|
|
Loading…
Reference in New Issue