Flowee the Hub — API documentation

Service/BlockNotification

Block Notification API

This is a subscription style service. Clients can subscribe to receive block notifications with NewBlockOnChain messages whenever a new block is found by the Hub.

The service ID for this service is 18.

Messages

Subscribe

Subscribing doesn’t require any special field, just a simple message.

Hub / BlockNotification. sId=18 mId=0

Unsubscribe

Unsubscribing doesn’t require any special field, just a simple message.

Hub / BlockNotification. sId=18 mId=2

NewBlockOnChain

Hub / BlockNotification. sId=18 mId=4
BlockHash: 5bytearray32-byte blockhash of the new block.
BlockHeight: 7numberHeight of the block in the chain.

BlocksRemoved

Normally blocks come in sequence, but sometimes two miners make a block at the same time and for a while there is insecurity which block becomes part of the chain. The Hub can thus have in this time either of the two blocks as its tip of the chain. And there is a risk that the Hub may have to revert its tip and switch over to the other block that was mined at the same time.

This event we call a reorg and while this kind of event is rare, it is a natural result of our decentralized nature. When the Hub encounters such an event it will let subscribers to the block notification service know.

The message sent by the Hub will repeat the BlockHash/BlockHeight pair for every block that was needed to be reverted. While 1-block reorgs are rare, multi-block ones are extremely rare. But we do allow for the situation and we send a BlockHash/BlockHeight pair for each of the blocks that gets reverted.

Hub / BlockNotification. sId=18 mId=6
BlockHash: 5bytearray32-byte blockhash of the old block.
BlockHeight: 7numberHeight the block in its chain.