Documentation ¶
Overview ¶
Package ouroboros implements support for interacting with Cardano nodes using the Ouroboros network protocol.
The Ouroboros network protocol consists of a muxer and multiple mini-protocols that provide various functions. A handshake and protocol versioning are used to ensure peer compatibility.
This package is the main entry point into this library. The other packages can be used outside of this one, but it's not a primary design goal.
Index ¶
- Variables
- type Network
- type Ouroboros
- func (o *Ouroboros) BlockFetch() *blockfetch.BlockFetch
- func (o *Ouroboros) ChainSync() *chainsync.ChainSync
- func (o *Ouroboros) Close() error
- func (o *Ouroboros) Dial(proto string, address string) error
- func (o *Ouroboros) ErrorChan() chan error
- func (o *Ouroboros) KeepAlive() *keepalive.KeepAlive
- func (o *Ouroboros) LocalStateQuery() *localstatequery.LocalStateQuery
- func (o *Ouroboros) LocalTxMonitor() *localtxmonitor.LocalTxMonitor
- func (o *Ouroboros) LocalTxSubmission() *localtxsubmission.LocalTxSubmission
- func (o *Ouroboros) Muxer() *muxer.Muxer
- func (o *Ouroboros) TxSubmission() *txsubmission.TxSubmission
- type OuroborosOptionFunc
- func WithBlockFetchConfig(cfg blockfetch.Config) OuroborosOptionFunc
- func WithChainSyncConfig(cfg chainsync.Config) OuroborosOptionFunc
- func WithConnection(conn net.Conn) OuroborosOptionFunc
- func WithDelayMuxerStart(delayMuxerStart bool) OuroborosOptionFunc
- func WithErrorChan(errorChan chan error) OuroborosOptionFunc
- func WithFullDuplex(fullDuplex bool) OuroborosOptionFunc
- func WithKeepAlive(keepAlive bool) OuroborosOptionFunc
- func WithKeepAliveConfig(cfg keepalive.Config) OuroborosOptionFunc
- func WithLocalStateQueryConfig(cfg localstatequery.Config) OuroborosOptionFunc
- func WithLocalTxSubmissionConfig(cfg localtxsubmission.Config) OuroborosOptionFunc
- func WithNetwork(network Network) OuroborosOptionFunc
- func WithNetworkMagic(networkMagic uint32) OuroborosOptionFunc
- func WithNodeToNode(nodeToNode bool) OuroborosOptionFunc
- func WithServer(server bool) OuroborosOptionFunc
- func WithTxSubmissionConfig(cfg txsubmission.Config) OuroborosOptionFunc
Constants ¶
This section is empty.
Variables ¶
var ( NetworkTestnet = Network{Id: 0, Name: "testnet", NetworkMagic: 1097911063} NetworkMainnet = Network{Id: 1, Name: "mainnet", NetworkMagic: 764824073, PublicRootAddress: "relays-new.cardano-mainnet.iohk.io", PublicRootPort: 3001} NetworkPreprod = Network{Id: 2, Name: "preprod", NetworkMagic: 1, PublicRootAddress: "preprod-node.world.dev.cardano.org", PublicRootPort: 30000} NetworkPreview = Network{Id: 3, Name: "preview", NetworkMagic: 2, PublicRootAddress: "preview-node.world.dev.cardano.org", PublicRootPort: 30002} NetworkInvalid = Network{Id: 0, Name: "invalid", NetworkMagic: 0} // NetworkInvalid is used as a return value for lookup functions when a network isn't found )
Network definitions
Functions ¶
This section is empty.
Types ¶
type Network ¶
type Network struct { Id uint Name string NetworkMagic uint32 PublicRootAddress string PublicRootPort uint }
Network represents a Cardano network
func NetworkByName ¶
NetworkByName returns a predefined network by name
func NetworkByNetworkMagic ¶
NetworkByNetworkMagic returns a predefined network by network magic
type Ouroboros ¶
type Ouroboros struct {
// contains filtered or unexported fields
}
The Ouroboros type is a wrapper around a net.Conn object that handles communication using the Ouroboros network protocol over that connection
func New ¶
func New(options ...OuroborosOptionFunc) (*Ouroboros, error)
New returns a new Ouroboros object with the specified options. If a connection is provided, the handshake will be started. An error will be returned if the handshake fails
func (*Ouroboros) BlockFetch ¶
func (o *Ouroboros) BlockFetch() *blockfetch.BlockFetch
BlockFetch returns the block-fetch protocol handler
func (*Ouroboros) Dial ¶
Dial will establish a connection using the specified protocol and address. These parameters are passed to the net.Dial func. The handshake will be started when a connection is established. An error will be returned if the connection fails, a connection was already established, or the handshake fails
func (*Ouroboros) LocalStateQuery ¶
func (o *Ouroboros) LocalStateQuery() *localstatequery.LocalStateQuery
LocalStateQuery returns the local-state-query protocol handler
func (*Ouroboros) LocalTxMonitor ¶
func (o *Ouroboros) LocalTxMonitor() *localtxmonitor.LocalTxMonitor
LocalTxMonitor returns the local-tx-monitor protocol handler
func (*Ouroboros) LocalTxSubmission ¶
func (o *Ouroboros) LocalTxSubmission() *localtxsubmission.LocalTxSubmission
LocalTxSubmission returns the local-tx-submission protocol handler
func (*Ouroboros) TxSubmission ¶
func (o *Ouroboros) TxSubmission() *txsubmission.TxSubmission
TxSubmission returns the tx-submission protocol handler
type OuroborosOptionFunc ¶
type OuroborosOptionFunc func(*Ouroboros)
OuroborosOptionFunc is a type that represents functions that modify the Ouroboros config
func WithBlockFetchConfig ¶
func WithBlockFetchConfig(cfg blockfetch.Config) OuroborosOptionFunc
WithBlockFetchConfig specifies BlockFetch protocol config
func WithChainSyncConfig ¶
func WithChainSyncConfig(cfg chainsync.Config) OuroborosOptionFunc
WithChainSyncConfig secifies ChainSync protocol config
func WithConnection ¶
func WithConnection(conn net.Conn) OuroborosOptionFunc
WithConnection specifies an existing connection to use. If none is provided, the Dial() function can be used to create one later
func WithDelayMuxerStart ¶
func WithDelayMuxerStart(delayMuxerStart bool) OuroborosOptionFunc
WithDelayMuxerStart specifies whether to delay the muxer start. This is useful if you need to take some custom actions before the muxer starts processing messages, generally when acting as a server
func WithErrorChan ¶
func WithErrorChan(errorChan chan error) OuroborosOptionFunc
WithErrorChan specifies the error channel to use. If none is provided, one will be created
func WithFullDuplex ¶
func WithFullDuplex(fullDuplex bool) OuroborosOptionFunc
WithFullDuplex specifies whether to enable full-duplex mode when acting as a client
func WithKeepAlive ¶
func WithKeepAlive(keepAlive bool) OuroborosOptionFunc
WithKeepAlives specifies whether to use keep-alives. This is disabled by default
func WithKeepAliveConfig ¶
func WithKeepAliveConfig(cfg keepalive.Config) OuroborosOptionFunc
WithKeepAliveConfig specifies KeepAlive protocol config
func WithLocalStateQueryConfig ¶
func WithLocalStateQueryConfig(cfg localstatequery.Config) OuroborosOptionFunc
WithLocalStateQueryConfig specifies LocalStateQuery protocol config
func WithLocalTxSubmissionConfig ¶
func WithLocalTxSubmissionConfig(cfg localtxsubmission.Config) OuroborosOptionFunc
WithLocalTxSubmissionConfig specifies LocalTxSubmission protocol config
func WithNetwork ¶
func WithNetwork(network Network) OuroborosOptionFunc
WithNetwork specifies the network
func WithNetworkMagic ¶
func WithNetworkMagic(networkMagic uint32) OuroborosOptionFunc
WithNetworkMagic specifies the network magic value
func WithNodeToNode ¶
func WithNodeToNode(nodeToNode bool) OuroborosOptionFunc
WithNodeToNode specifies whether to use the node-to-node protocol. The default is to use node-to-client
func WithServer ¶
func WithServer(server bool) OuroborosOptionFunc
WithServer specifies whether to act as a server
func WithTxSubmissionConfig ¶
func WithTxSubmissionConfig(cfg txsubmission.Config) OuroborosOptionFunc
WithTxSubmissionConfig specifies TxSubmission protocol config
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package muxer implements the muxer/demuxer that allows multiple mini-protocols to run over a single connection.
|
Package muxer implements the muxer/demuxer that allows multiple mini-protocols to run over a single connection. |
Package protocol provides the common functionality for mini-protocols
|
Package protocol provides the common functionality for mini-protocols |
chainsync
Package chainsync implements the Ouroboros chain-sync protocol
|
Package chainsync implements the Ouroboros chain-sync protocol |
common
The common package contains types used by multiple mini-protocols
|
The common package contains types used by multiple mini-protocols |
handshake
Package handshake implements the Ouroboros handshake protocol
|
Package handshake implements the Ouroboros handshake protocol |
localstatequery
Package localstatequery implements the Ouroboros local-state-query protocol
|
Package localstatequery implements the Ouroboros local-state-query protocol |
localtxmonitor
Package localtxmonitor implements the Ouroboros local-tx-monitor protocol
|
Package localtxmonitor implements the Ouroboros local-tx-monitor protocol |
localtxsubmission
Package localtxsubmission implements the Ouroboros local-tx-submission protocol
|
Package localtxsubmission implements the Ouroboros local-tx-submission protocol |
Package utils provides random utility functions
|
Package utils provides random utility functions |