Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Oct 31, 2023
1 parent 327555f commit aa11da1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions evilwallet/output_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,13 @@ func (o *OutputManager) AwaitOutputToBeAccepted(outputID iotago.OutputID, waitFo
}

func (o *OutputManager) AwaitAddressUnspentOutputToBeAccepted(addr *iotago.Ed25519Address, waitFor time.Duration) (outputID iotago.OutputID, output iotago.Output, err error) {
s := time.Now()

clt := o.connector.GetIndexerClient()
indexer, err := clt.Indexer()
if err != nil {
return iotago.EmptyOutputID, nil, ierrors.Wrap(err, "failed to get indexer client")
}

s := time.Now()
addrBech := addr.Bech32(clt.CommittedAPI().ProtocolParameters().Bech32HRP())

for ; time.Since(s) < waitFor; time.Sleep(awaitAcceptationSleep) {
Expand All @@ -286,15 +285,15 @@ func (o *OutputManager) AwaitAddressUnspentOutputToBeAccepted(addr *iotago.Ed255
}

if len(unspents) == 0 {
o.log.Debugf("no unspent outputs found for address: %s", addrBech)
o.log.Debugf("no unspent outputs found in indexer for address: %s", addrBech)
break
}

return lo.Return1(res.Response.Items.OutputIDs())[0], unspents[0], nil
}
}

return iotago.EmptyOutputID, nil, ierrors.Errorf("no unspent outputs found for address %s due to timeout", addr.Bech32(clt.CommittedAPI().ProtocolParameters().Bech32HRP()))
return iotago.EmptyOutputID, nil, ierrors.Errorf("no unspent outputs found for address %s due to timeout", addrBech)
}

// AwaitTransactionsAcceptance awaits for transaction confirmation and updates wallet with outputIDs.
Expand Down

0 comments on commit aa11da1

Please sign in to comment.