aeternity / aepp-sdk-go

Golang SDK to interact with the Æternity blockchain
ISC License
18 stars 10 forks source link

Ae.WaitForTransactionUntilHeight: use /transactions/(txhash) to find information #55

Closed randomshinichi closed 4 years ago

randomshinichi commented 5 years ago

The current Ae.WaitForTransactionUntilHeight() does the following:

  1. Get current generation
  2. Get each microblock (each one is a HTTP request)
  3. Look for the txhash.

This is inefficient and the code is rather convoluted (2 for loops with minor variable scoping issues) I think the /transactions/(txhash) is already available even if the transaction is not yet in a microblock. If that is the case, it is a simple matter to:

  1. Poll /transactions/txhash until a microblock hash is mentioned and /blocks/top to get current height
  2. Fetch info about the microblock.

EDIT: surprisingly complicated. Needs proper Big Integer support.