The bstream
package manages flows of blocks and forks in a blockchain
through a Handler-based interface similar to net/http
.
Flows are composed by assembling Handler
s:
type HandlerFunc func(blk *pbbstream.Block, obj interface{}) error
and are kicked off by passing them to a Source
All streaming features of streamingfast use this package.
Sources include:
- FileSource feeds from 100-blocks files in some dstore-based location (some object storage, or local filesystem files)
- LiveSource streams from a gRPC-based block streamer (fed from instrumented blockchain nodes directly).
- JoiningSource which bridges a FileSource and a LiveSource transparently, so you can stream from files and then handoff to a real-time stream.
Handlers include:
- Forkable (in
forkable/
) which manages chain reorganizations, undos, according to the chain's consensus (longest chain, etc..) - SubscriptionHub (in
hub/
): In-process hub to dispatch blocks from a remote source to all consumers inside a Go process - A few gates, that allow the flowing of blocks only upon certain conditions (BlockNumGate, BlockIDGate, RealtimeGate, RealtimeTripper, which can be inclusive or exclusive). See gates.go.
Issues and PR in this repo related strictly to the low-level functionalities of bstream
Report any protocol-specific issues in their respective repositories
Please first refer to the general StreamingFast contribution guide, if you wish to contribute to this code base.