Add get_header_by_hash client method#585
Conversation
Allows client to retrieve header in case of reorg.
|
|
|
I think you're right and even if a consumer receives However I've just realized there can be a bug when we reorganize from longer chain with less amount of work: if we are at block 110 and we reorganize to another chain with the tip at block 105' (but with more work), then when we call |
|
It should not be possible to be on a longer chain that has less work in practice. We audit that the difficulty adjustment is adhered to, so all blocks will be approximately the same work given a block height. |
Allows client to retrieve block header by its hash.
Motivation: when we listen for kyoto events, we receive
Event::IndexedFilterwhich has only height value there. By the moment we process this event, the header chain could have reorganized from the canonical chain, and when we retrieve the header, we actually retrieve a stale one.Right now we can just check if retrieved header is the right one, but we cannot get the right header via hash.