I’ve started to build this app called PayForSpace really fast and one thing I don’t like about this thing is that I am forced to make compromises.
After I checked out the Elrond gateway documentation, I saw that I am only able to get the last 20 transactions and that includes both sent or received transactions. So while this would be mostly ok for any use-case I can imagine, I still don’t like to have a limitation from the start.
So tonight I thought about adding a long-polling command that uses another API endpoint that allows much more transactions in a single request to be returned. The only drawback to this approach is that this new command must run in order to be able to validate incoming transactions. This might not be ideal for some use-cases and since this app is open source, I have to think in more scenarios.
So basically we’re implementing this new way to validate transactions and also keep them locally BUT we’re adding a configuration key to specify the method to use: the simple and classic one that does not require a background process but is limited to 20 transactions or a more advanced method that copies every incoming transaction locally and then we can use our own table to validate a transaction.
This is what we did in this short 1-hour stream, which by the way was not planned at all:
- Built a new console command
\App\Console\Commands\SyncBlockchainTransactionswhich you can call in the terminal as
php artisan sync:blockchain-transaction
- We built the Transaction model along with a new migration and it’s own table
- The new command checks for new transactions every 10 seconds and stores them locally (
hash, value, data, object) only if we don’t have them stored already
- We refactored the component that checks for the incoming transactions and then reserves the spot to work with both methods, we had to adapt the code a bit to make it work in both ways
That’s all and it might seem like not a lot has changed, but now we do have a more robust way to check for incoming transactions and have a copy locally too. I like this approach a lot and also we’re no longer limited.
Hope you enjoyed the stream, you can watch it anytime below or here.