Documentation ¶
Overview ¶
Package proxy defines and implements AppProxy: the interface between Babble and an application.
Babble communicates with the App through an AppProxy interface, which has two implementations:
- SocketProxy: A SocketProxy connects to an App via TCP sockets. It enables the application to run in a separate process or machine, and to be written in any programming language.
- InmemProxy: An InmemProxy uses native callback handlers to integrate Babble as a regular Go dependency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppProxy ¶
type AppProxy interface { SubmitCh() chan []byte CommitBlock(block hashgraph.Block) (CommitResponse, error) GetSnapshot(blockIndex int) ([]byte, error) Restore(snapshot []byte) error OnStateChanged(state.State) error }
AppProxy defines the interface which is used by Babble to communicate with the App
type CommitCallback ¶ added in v0.4.1
type CommitCallback func(block hashgraph.Block) (CommitResponse, error)
CommitCallback ...
type CommitResponse ¶ added in v0.4.1
type CommitResponse struct { StateHash []byte InternalTransactionReceipts []hashgraph.InternalTransactionReceipt }
CommitResponse ...
func DummyCommitCallback ¶ added in v0.4.1
func DummyCommitCallback(block hashgraph.Block) (CommitResponse, error)
DummyCommitCallback is used for testing
type ProxyHandler ¶
type ProxyHandler interface { // CommitHandler is called when Babble commits a block to the application CommitHandler(block hashgraph.Block) (response CommitResponse, err error) // SnapshotHandler is called by Babble to retrieve a snapshot corresponding // to a particular block SnapshotHandler(blockIndex int) (snapshot []byte, err error) // RestoreHandler is called by Babble to restore the application to a // specific state RestoreHandler(snapshot []byte) (stateHash []byte, err error) // StateChangeHandler is called by onStateChanged to notify that a Babble // node entered a certain state StateChangeHandler(state.State) error }
ProxyHandler encapsulates callbacks to be called by the InmemProxy. This is the true contact surface between Babble and the Application. The application must implement these handlers to process incoming Babble blocks and state changes. The Snapshot and Restore handlers are necessary only with fast-sync, which is still experimental, so can safely be empty.
Directories ¶
Path | Synopsis |
---|---|
Package inmem implements an in-memory AppProxy to use Babble directly from Go code.
|
Package inmem implements an in-memory AppProxy to use Babble directly from Go code. |
Package socket implements both sides of a TCP AppProxy to run Babble and the application in separate processes.
|
Package socket implements both sides of a TCP AppProxy to run Babble and the application in separate processes. |
app
Package app implements a TCP AppProxy which resides inside Babble and connects to the other side of the proxy.
|
Package app implements a TCP AppProxy which resides inside Babble and connects to the other side of the proxy. |
babble
Package babble implements a component that the TCP AppProxy can connect to.
|
Package babble implements a component that the TCP AppProxy can connect to. |