why eosjs return ref_block_num is very different from eos ' block number ???
My understanding should be the same,Did I misunderstand these two parameters??
eosio produce block 1888500ms thread-0 producer_plugin.cpp:917 produce_block ] Produced block 0002650626e3f453... #156934 @ 2018-05-31T13:31:28.500 signed by eosio [trxs: 0, lib: 156933, confirmed: 0] 1889008ms thread-0 producer_plugin.cpp:917 produce_block ] Produced block 000265079acc402a... #156935 @ 2018-05-31T13:31:29.000 signed by eosio [trxs: 0, lib: 156934, confirmed: 0]
{ "data": { "transaction_id": "d3490a3f1d815df731daea5e31e89dcdcd697e9ea8a91c80c96663ec61caf03e", "broadcast": true, "transaction": { "compression": "none", "transaction": { "expiration": "2018-05-31T13:31:29", "ref_block_num": 25741, "ref_block_prefix": 2976788490, "net_usage_words": 0, "max_cpu_usage_ms": 0, "delay_sec": 0, "context_free_actions": [], "actions": [ { "account": "liontoken", "name": "transfer", "authorization": [ { "actor": "liontoken", "permission": "active" } ], "data": "0000980ad23ca98b0000000000ea30550a00000000000000004c4f4e00000000087472616e73666572" } ], "transaction_extensions": [] }, "signatures": [ "SIG_K1_JuqwkDteM8LQZMDXM9aR453xKnE5Kq8BeEja1s7tn6YX5rFaH6kLa9ai5BVxenbPB62sQVtykbFq1kbeeXKKeCLyyQvcuP" ] } }, "status": 200, "msg": "success" }
It is shortened:
const ref_block_num = (info.last_irreversible_block_num) & 0xFFFF
When combined with ref_block_prefix it strengthens the block identified in the transaction.
Recent head block number (ideally last irreversible block). The bit-wise AND operation is used to keep this value with the size of a Uint16 size. Example:(get_info.last_irreversible_block_num) & 0xFFFF
https://github.com/EOSIO/eosjs-api/blob/master/docs/index.md#headers--object
ref_block_num specifies a block num in the last 2^16 blocks.
ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]) // _hash[0] first 16 bits of block id
how to get all ref_block_num ,not 2^16 blocks??
Can you look it up by the transaction ID?
If not, I would have to investigate, I suspect the block needs to be fetched by ref_block_num and ref_block_prefix..
Use eos.getTransaction(id) then it returns the block_num..
ok,thanks