blocksync

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0, MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BSOptBlocks = 1 << iota
	BSOptMessages
)
View Source
const (
	StatusOK            = uint64(0)
	StatusPartial       = uint64(101)
	StatusNotFound      = uint64(201)
	StatusGoAway        = uint64(202)
	StatusInternalError = uint64(203)
	StatusBadRequest    = uint64(204)
)
View Source
const BlockSyncMaxRequestLength = 800
View Source
const BlockSyncProtocolID = "/fil/sync/blk/0.0.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type BSOptions

type BSOptions struct {
	IncludeBlocks   bool
	IncludeMessages bool
}

func ParseBSOptions

func ParseBSOptions(optfield uint64) *BSOptions

type BSTipSet

type BSTipSet struct {
	Blocks []*types.BlockHeader

	BlsMessages    []*types.Message
	BlsMsgIncludes [][]uint64

	SecpkMessages    []*types.SignedMessage
	SecpkMsgIncludes [][]uint64
}

func (*BSTipSet) MarshalCBOR

func (t *BSTipSet) MarshalCBOR(w io.Writer) error

func (*BSTipSet) UnmarshalCBOR

func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error

type BlockSync

type BlockSync struct {
	// contains filtered or unexported fields
}

func (*BlockSync) AddPeer

func (bs *BlockSync) AddPeer(p peer.ID)

func (*BlockSync) FetchMessagesByCids

func (bs *BlockSync) FetchMessagesByCids(ctx context.Context, cids []cid.Cid) ([]*types.Message, error)

func (*BlockSync) FetchSignedMessagesByCids

func (bs *BlockSync) FetchSignedMessagesByCids(ctx context.Context, cids []cid.Cid) ([]*types.SignedMessage, error)

func (*BlockSync) GetBlock

func (bs *BlockSync) GetBlock(ctx context.Context, c cid.Cid) (*types.BlockHeader, error)

func (*BlockSync) GetBlocks

func (bs *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 (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, count uint64) ([]*BSTipSet, error)

func (*BlockSync) GetFullTipSet

func (bs *BlockSync) GetFullTipSet(ctx context.Context, p peer.ID, tsk types.TipSetKey) (*store.FullTipSet, error)

func (*BlockSync) RemovePeer

func (bs *BlockSync) RemovePeer(p peer.ID)

type BlockSyncRequest

type BlockSyncRequest struct {
	Start         []cid.Cid
	RequestLength uint64

	Options uint64
}

func (*BlockSyncRequest) MarshalCBOR

func (t *BlockSyncRequest) MarshalCBOR(w io.Writer) error

func (*BlockSyncRequest) UnmarshalCBOR

func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error

type BlockSyncResponse

type BlockSyncResponse struct {
	Chain []*BSTipSet

	Status  uint64
	Message string
}

func (*BlockSyncResponse) MarshalCBOR

func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error

func (*BlockSyncResponse) UnmarshalCBOR

func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error

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.

func NewBlockSyncService

func NewBlockSyncService(cs *store.ChainStore) *BlockSyncService

func (*BlockSyncService) HandleStream

func (bss *BlockSyncService) HandleStream(s inet.Stream)

type NewStreamFunc

type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)

Jump to

Keyboard shortcuts

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