Documentation ¶
Index ¶
- Constants
- Variables
- type BSTipSet
- type BlockSync
- func (client *BlockSync) AddPeer(p peer.ID)
- func (client *BlockSync) GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error)
- func (client *BlockSync) GetChainMessages(ctx context.Context, head *types.TipSet, length uint64) ([]*CompactedMessages, error)
- func (client *BlockSync) GetFullTipSet(ctx context.Context, peer peer.ID, tsk types.TipSetKey) (*store.FullTipSet, error)
- func (client *BlockSync) RemovePeer(p peer.ID)
- type BlockSyncService
- type CompactedMessages
- type Request
- type Response
Constants ¶
const ( Headers = 1 << iota Messages )
Request options. When fetching the chain segment we can fetch either block headers, messages, or both.
const ( Ok status = 0 // We could not fetch all blocks requested (but at least we returned // the `Head` requested). Not considered an error. Partial = 101 // Errors NotFound = 201 GoAway = 202 InternalError = 203 BadRequest = 204 )
const BlockSyncProtocolID = "/fil/sync/blk/0.0.1"
const READ_RES_DEADLINE = WRITE_REQ_DEADLINE
const READ_RES_MIN_SPEED = 50 << 10
const SHUFFLE_PEERS_PREFIX = 5
const SUCCESS_PEER_TAG_VALUE = 25
Extracted constants from the code. FIXME: Should be reviewed and confirmed.
const WRITE_REQ_DEADLINE = 5 * time.Second
const WRITE_RES_DEADLINE = 60 * time.Second
Variables ¶
var MaxRequestLength = uint64(build.ForkLengthThreshold)
FIXME: Bumped from original 800 to this to accommodate `syncFork()`
use of `GetBlocks()`. It seems the expectation of that API is to fetch any amount of blocks leaving it to the internal logic here to partition and reassemble the requests if they go above the maximum. (Also as a consequence of this temporarily removing the `const` qualifier to avoid "const initializer [...] is not a constant" error.)
Functions ¶
This section is empty.
Types ¶
type BSTipSet ¶
type BSTipSet struct { Blocks []*types.BlockHeader Messages *CompactedMessages }
FIXME: Rename.
type BlockSync ¶
type BlockSync struct {
// contains filtered or unexported fields
}
Protocol client. FIXME: Rename to just `Client`. Not done at the moment to avoid
disrupting too much of the consumer code, should be done along https://github.com/filecoin-project/lotus/issues/2612.
func NewClient ¶ added in v0.5.0
func NewClient( host host.Host, pmgr peermgr.MaybePeerMgr, ) *BlockSync
func (*BlockSync) GetBlocks ¶
func (client *BlockSync) GetBlocks( ctx context.Context, tsk types.TipSetKey, count int, ) ([]*types.TipSet, error)
GetBlocks fetches count blocks from the network, from the provided tipset *backwards*, returning as many tipsets as count.
{hint/usage}: This is used by the Syncer during normal chain syncing and when resolving forks.
func (*BlockSync) GetChainMessages ¶
func (*BlockSync) GetFullTipSet ¶
func (*BlockSync) RemovePeer ¶
type BlockSyncService ¶
type BlockSyncService struct {
// contains filtered or unexported fields
}
BlockSyncService is the component that services BlockSync requests from peers.
BlockSync is the basic chain synchronization protocol of Filecoin. BlockSync is an RPC-oriented protocol, with a single operation to request blocks.
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. FIXME: Rename to just `Server` (will be done later, see note on `BlockSync`).
func NewBlockSyncService ¶
func NewBlockSyncService(cs *store.ChainStore) *BlockSyncService
func (*BlockSyncService) HandleStream ¶
func (server *BlockSyncService) HandleStream(stream inet.Stream)
Entry point of the service, handles `Request`s.
type CompactedMessages ¶ added in v0.5.0
type CompactedMessages struct { Bls []*types.Message BlsIncludes [][]uint64 Secpk []*types.SignedMessage SecpkIncludes [][]uint64 }
All messages of a single tipset compacted together instead of grouped by block to save space, since there are normally many repeated messages per tipset in different blocks.
`BlsIncludes`/`SecpkIncludes` matches `Bls`/`Secpk` messages to blocks in the tipsets with the format: `BlsIncludes[BI][MI]`
- BI: block index in the tipset.
- MI: message index in `Bls` list
FIXME: The logic to decompress this structure should belong
to itself, not to the consumer.
func (*CompactedMessages) MarshalCBOR ¶ added in v0.5.0
func (t *CompactedMessages) MarshalCBOR(w io.Writer) error
func (*CompactedMessages) UnmarshalCBOR ¶ added in v0.5.0
func (t *CompactedMessages) UnmarshalCBOR(r io.Reader) error
type Request ¶ added in v0.5.0
type Request struct { // List of ordered CIDs comprising a `TipSetKey` from where to start // fetching backwards. // FIXME: Consider using `TipSetKey` now (introduced after the creation // of this protocol) instead of converting back and forth. Head []cid.Cid // Number of block sets to fetch from `Head` (inclusive, should always // be in the range `[1, MaxRequestLength]`). Length uint64 // Request options, see `Options` type for more details. Compressed // in a single `uint64` to save space. Options uint64 }
FIXME: Rename. Make private.