Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBadResponseType is returned when a call to a peer returns an // unexpected response type. ErrBadResponseType = errors.New("bad response type") )
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder interface {
Encode(interface{}) error
}
Encoder is an interface that implements an Encode method.
type P2P ¶
type P2P interface {
// RequestHeaderByHash request a header given its hash from a peer.
RequestHeaderByHash(ctx context.Context, peerID peer.ID, hash []byte) (*pb.Header, error)
// RequestBlockByHash request a block given its header's hash from a peer.
RequestBlockByHash(ctx context.Context, peerID peer.ID, hash []byte) (*pb.Block, error)
// RequestHeadersByNumber request a batch of headers within a range in the main branch of a peer.
RequestHeadersByNumber(ctx context.Context, peerID peer.ID, from, amount uint64) ([]*pb.Header, error)
// RequestHeadersByNumber request a batch of blocks within a range in the main branch of a peer.
RequestBlocksByNumber(ctx context.Context, peerID peer.ID, from, amount uint64) ([]*pb.Block, error)
// RespondHeaderByHash responds to a HeaderRequest.
RespondHeaderByHash(ctx context.Context, req *pb.HeaderRequest, enc Encoder, chain chain.Reader) error
// RespondHeadersByNumber responds to a HeadersRequest.
RespondHeadersByNumber(ctx context.Context, req *pb.HeadersRequest, enc Encoder, c chain.Reader) error
// RespondBlockByHash responds to a BlockRequest.
RespondBlockByHash(ctx context.Context, req *pb.BlockRequest, enc Encoder, chain chain.Reader) error
// RespondBlocksByNumber responds to a BlocksRequest.
RespondBlocksByNumber(ctx context.Context, req *pb.BlocksRequest, enc Encoder, c chain.Reader) error
}
P2P is where the p2p APIs are defined.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mockencoder is a generated GoMock package.
|
Package mockencoder is a generated GoMock package. |
|
Package mockp2p is a generated GoMock package.
|
Package mockp2p is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.