Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (client *Client) Close(reason string)
- func (client *Client) GetBlockChainHeight() (*pb.DownloaderResponse, error)
- func (client *Client) GetBlockHashes(startHash []byte, size uint32, ip, port string) *pb.DownloaderResponse
- func (client *Client) GetBlockHeaders(hashes [][]byte) *pb.DownloaderResponse
- func (client *Client) GetBlocks(hashes [][]byte) *pb.DownloaderResponse
- func (client *Client) GetBlocksAndSigs(hashes [][]byte) *pb.DownloaderResponse
- func (client *Client) GetBlocksByHeights(heights []uint64) *pb.DownloaderResponse
- func (client *Client) IsConnecting() bool
- func (client *Client) IsReady() bool
- func (client *Client) PushNewBlock(selfPeerHash [20]byte, blockBytes []byte, timeout bool) (*pb.DownloaderResponse, error)
- func (client *Client) Register(hash []byte, ip, port string) *pb.DownloaderResponse
- func (client *Client) State() connectivity.State
- func (client *Client) WaitForConnection(t time.Duration) bool
- type DownloadInterface
- type Server
Constants ¶
const (
DefaultDownloadPort = "6666"
)
Constants for downloader server.
Variables ¶
var (
ErrDownloaderWithNoNode = errors.New("no node attached")
)
Errors for downloader package.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client model for downloader package.
func ClientSetup ¶
ClientSetup setups a Client given ip and port.
func (*Client) GetBlockChainHeight ¶
func (client *Client) GetBlockChainHeight() (*pb.DownloaderResponse, error)
GetBlockChainHeight gets the blockheight from peer
func (*Client) GetBlockHashes ¶
func (client *Client) GetBlockHashes(startHash []byte, size uint32, ip, port string) *pb.DownloaderResponse
GetBlockHashes gets block hashes from all the peers by calling grpc request.
func (*Client) GetBlockHeaders ¶
func (client *Client) GetBlockHeaders(hashes [][]byte) *pb.DownloaderResponse
GetBlockHeaders gets block headers in serialization byte array by calling a grpc request.
func (*Client) GetBlocks ¶
func (client *Client) GetBlocks(hashes [][]byte) *pb.DownloaderResponse
GetBlocks gets blocks in serialization byte array by calling a grpc request.
func (*Client) GetBlocksAndSigs ¶
func (client *Client) GetBlocksAndSigs(hashes [][]byte) *pb.DownloaderResponse
GetBlocksAndSigs get blockWithSig in serialization byte array by calling a grpc request
func (*Client) GetBlocksByHeights ¶
func (client *Client) GetBlocksByHeights(heights []uint64) *pb.DownloaderResponse
GetBlocksByHeights gets blocks from peers by calling grpc request.
func (*Client) IsConnecting ¶
IsConnecting returns true if client is connecting
func (*Client) PushNewBlock ¶
func (client *Client) PushNewBlock(selfPeerHash [20]byte, blockBytes []byte, timeout bool) (*pb.DownloaderResponse, error)
PushNewBlock will send the lastest verified block to registered nodes
func (*Client) Register ¶
func (client *Client) Register(hash []byte, ip, port string) *pb.DownloaderResponse
Register will register node's ip/port information to peers receive newly created blocks in future hash is the bytes of "ip:port" string representation
func (*Client) State ¶
func (client *Client) State() connectivity.State
State returns current Connecting state
type DownloadInterface ¶
type DownloadInterface interface { // State Syncing server-side interface, responsible for all kinds of state syncing grpc calls // incomingPeer is incoming peer ip:port information CalculateResponse(request *pb.DownloaderRequest, incomingPeer string) (*pb.DownloaderResponse, error) }
DownloadInterface is the interface for downloader package.
type Server ¶
type Server struct { pb.UnimplementedDownloaderServer GrpcServer *grpc.Server Port int // contains filtered or unexported fields }
Server is the Server struct for downloader package.
func NewServer ¶
func NewServer(dlInterface DownloadInterface, port int) *Server
NewServer creates new Server which implements DownloadInterface.
func (*Server) Query ¶
func (s *Server) Query(ctx context.Context, request *pb.DownloaderRequest) (*pb.DownloaderResponse, error)
Query returns the feature at the given point.