exchange

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2023 License: Apache-2.0, MIT Imports: 20 Imported by: 1

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

View Source
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

func GatherMessages(ctx context.Context, cr chainReader, mr messageStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error)

func NewInct

func NewInct(rd ReaderDeadline, minSpeed int64, maxWait time.Duration) io.Reader

New creates an Incremental Reader Timeout, with minimum sustained speed of minSpeed bytes per second and with maximum wait of maxWait

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.

func NewClient

func NewClient(host host.Host, pmgr peermgr.IPeerMgr) Client

NewClient creates a new libp2p-based exchange.Client that uses the libp2p ChainExhange protocol as the fetching mechanism.

type ReaderDeadline

type ReaderDeadline interface {
	Read([]byte) (int, error)
	SetReadDeadline(time.Time) error
}

type Server

type Server interface {
	Register()
}

Server is the responder side of the ChainExchange protocol. It accepts requests from clients and services them by returning the requested chain data.

func NewServer

func NewServer(cr chainReader, mr messageStore, h host.Host) Server

NewServer creates a new libp2p-based exchange.Server. It services requests for the libp2p ChainExchange protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL