Bitcoin full node and query server

Jul 23, 2021

View in context in the libbitcoin Slack #general mirror.

P
Phil02:29
Eric thanks a lot for clarifying! That is that a full_node’s subscribe_headers() and subscribe_blocks() only regard headers/blocks where the node has a whole header/block chain already that includes covers said header/block. Apologies if the following appears like asking doubly however I wish to get great clarity on this. To really get it, I’ll describe the context first: So a node firstly receives block headers. This becomes one whole set Htot, of all headers it received. It’s an array sorted in ascending order of time received. The node basically calculates a function most_work_header_chain(Htot) -> Hmostwork . Hmostwork is a deterministic function of Htot. What you are saying then is that subscribe_headers() will produce a callback at any change to Htot. And then, a node receives blocks. A node will only receive blocks that it has headers for, either by a whole block dropping in in one piece (in which case the header would be added to Htot), or through that a node asks for the block that corresponds to a given header. Received blocks become one whole set Btot. It’s an array sorted in ascending order of time received. map(block_get_header,Btot) is always a subset of Htot. subscribe_blocks() will produce a callback at any change of Btot. My question to you now is this: The node tracks a main full blockchain, we can call it Bmostwork. What is the correlation between Hmostwork and Bmostwork actually??? Please explain. For instance, is LB implemented in such a way that map(block_get_header,Bmostwork) is always a subset of Hmostwork - I presume **NOT***? Please confirm? But then, may there be moments when Hmostwork and Bmostwork are different chains altogether? (As in that Hmostwork does not contain block_get_header(tail(Bmostwork,1)) *AND* map(block_get_header,Bmostwork) does not contain tail(Hmostwork,1). On this one I’m unclear. Your clarification of how LB does this would be very much appreciated, thanks!