Documentation ¶
Overview ¶
Package exchange contains the ChainExchange server and client components.
ChainExchange is the basic chain synchronization protocol of Filecoin. ChainExchange is an RPC-oriented protocol, with a single operation to request blocks for now.
A request contains a start anchor block (referred to with a CID), and a amount of blocks requested beyond the anchor (including the anchor itself).
A client can also pass options, encoded as a 64-bit bitfield. Lotus supports two options at the moment:
- include block contents
- include block messages
The response will include a status code, an optional message, and the response payload in case of success. The payload is a slice of serialized tipsets.
Index ¶
- Constants
- func GatherMessages(ctx context.Context, cr chainReader, mr messageStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error)
- func NewInct(rd ReaderDeadline, minSpeed int64, maxWait time.Duration) io.Reader
- type Client
- type ReaderDeadline
- type Server
Constants ¶
const ( // Extracted constants from the code. // FIXME: Should be reviewed and confirmed. SuccessPeerTagValue = 25 WriteReqDeadline = 5 * time.Second ReadResDeadline = WriteReqDeadline ReadResMinSpeed = 50 << 10 ShufflePeersPrefix = 16 WriteResDeadline = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func GatherMessages ¶
Types ¶
type Client ¶
type Client interface { // GetBlocks fetches block headers from the network, from the provided // tipset *backwards*, returning as many tipsets as the count parameter, // or less. GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error) // GetChainMessages fetches messages from the network, starting from the first provided tipset // and returning messages from as many tipsets as requested or less. GetChainMessages(ctx context.Context, tipsets []*types.TipSet) ([]*exchange.CompactedMessages, error) // GetFullTipSet fetches a full tipset from a given peer. If successful, // the fetched object contains block headers and all messages in full form. GetFullTipSet(ctx context.Context, peer []peer.ID, tsk types.TipSetKey) (*types.FullTipSet, error) // AddPeer adds a peer to the pool of peers that the Client requests // data from. AddPeer(peer peer.ID) // RemovePeer removes a peer from the pool of peers that the Client // requests data from. RemovePeer(peer peer.ID) }
Client is the requesting side of the ChainExchange protocol. It acts as a proxy for other components to request chain data from peers. It is chiefly used by the Syncer.