[SteemSQL Wrapper] Added the info about the delay to API

Words
150
Reading
1 min
9y
Listen to this post
~1 min

Right now SteemSQL has some issues with performances because of the blockchain size and speed (today Steemit has the biggest number of transactions per day). UPDATE: sorry, it is incorrect, see the arcange's comment.

The result is that SteemSQL sometimes has lagged — for example, right now (when I am writing this post) the delay is 228 minutes. And the lack of information about the delay is a problem for some users.

So I updated SteemSQL Wrapper — now you can get the info about the delay from API.

Example:

curl https://sql.steemhelpers.com/delay
{"delay_seconds": 12018}

The homepage also updated and you can check the delay right on it.

image.png

How this works

  • Firstly, I get the creation date of the last block from SteemSQL
SELECT TOP 1 timestamp FROM Blocks ORDER BY block_num DESC
  • Secondly, I get the creation date of the last block from the blockchain.
blockchain = steem.blockchain.Blockchain()
steemd = steem.steemd.Steemd()
current_block_num = blockchain.get_current_block_num()
current_block = steemd.get_block_header(current_block_num)
blockchain_last_date = datetime.strptime(current_block['timestamp'], "%Y-%m-%dT%H:%M:%S")
  • Thirdly, I compare these two dates.
delay = blockchain_last_date - steemsql_last_date

Commit #1
Commit #2

image



Posted on Utopian.io - Rewarding Open Source Contributors

[SteemSQL Wrapper] Added the info about the delay to API | Ecency