Created
June 23, 2021 14:46
-
-
Save andrewkkchan/f2d570d0801372265ffdf1853bc20172 to your computer and use it in GitHub Desktop.
Order Chain at Hyper ledger Fabric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Chain defines a way to inject messages for ordering. | |
// Note, that in order to allow flexibility in the implementation, it is the responsibility of the implementer | |
// to take the ordered messages, send them through the blockcutter.Receiver supplied via HandleChain to cut blocks, | |
// and ultimately write the ledger also supplied via HandleChain. This design allows for two primary flows | |
// 1. Messages are ordered into a stream, the stream is cut into blocks, the blocks are committed (solo, kafka) | |
// 2. Messages are cut into blocks, the blocks are ordered, then the blocks are committed (sbft) | |
type Chain interface { | |
// Order accepts a message which has been processed at a given configSeq. | |
// If the configSeq advances, it is the responsibility of the consenter | |
// to revalidate and potentially discard the message | |
// The consenter may return an error, indicating the message was not accepted | |
Order(env *cb.Envelope, configSeq uint64) error | |
// Configure accepts a message which reconfigures the channel and will | |
// trigger an update to the configSeq if committed. The configuration must have | |
// been triggered by a ConfigUpdate message. If the config sequence advances, | |
// it is the responsibility of the consenter to recompute the resulting config, | |
// discarding the message if the reconfiguration is no longer valid. | |
// The consenter may return an error, indicating the message was not accepted | |
Configure(config *cb.Envelope, configSeq uint64) error | |
// WaitReady blocks waiting for consenter to be ready for accepting new messages. | |
// This is useful when consenter needs to temporarily block ingress messages so | |
// that in-flight messages can be consumed. It could return error if consenter is | |
// in erroneous states. If this blocking behavior is not desired, consenter could | |
// simply return nil. | |
WaitReady() error | |
// Errored returns a channel which will close when an error has occurred. | |
// This is especially useful for the Deliver client, who must terminate waiting | |
// clients when the consenter is not up to date. | |
Errored() <-chan struct{} | |
// Start should allocate whatever resources are needed for staying up to date with the chain. | |
// Typically, this involves creating a thread which reads from the ordering source, passes those | |
// messages to a block cutter, and writes the resulting blocks to the ledger. | |
Start() | |
// Halt frees the resources which were allocated for this Chain. | |
Halt() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment