I wonder if there is any system in values for stellar horizon cursors.
I tried to ask testnet horizon for ledgers, starting from https://horizon-testnet.stellar.org/ledgers/ and then pressing next link. I'm getting cursor values:
42949672960 85899345920 128849018880 171798691840
They seem to be senseless, but if we convert them to binary:
101000000000000000000000000000000000_2, 1010000000000000000000000000000000000_2, 1111000000000000000000000000000000000_2, 10100000000000000000000000000000000000_2,
we can see that most part of them is zero. Definitely, last 32 bits are zero ones. Also. If we convert some number to binary and then append 32 bytes to its tail, we will get a cursor which points to an ledger + 1.
Example. Let ledger number will be
100500, then its binary representation is
11000100010010100_2. If we append 32 zero bits to it, and we will get
1100010001001010000000000000000000000000000000000_2, which is
431644213248000_10, then we go to the horizon: https://horizon-testnet.stellar.org/ledgers/?cursor=431644213248000&limit=1&order=asc and see that ledger number is 100501.
This phenomenon is not documented anywhere.
Could anyone answer why we just can't put there 64-bit long ledger sequence and not confuse everyone who tries to understand what is a horizon cursor? Connected questions, will this method work on other horizon instances? Will it work on other tables?