downloader

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDownloadPort = "6666"
)

Constants for downloader server.

Variables

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

func ClientSetup(ip, port string) *Client

ClientSetup setups a Client given ip and port.

func (*Client) Close

func (client *Client) Close()

Close closes the Client.

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) 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

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.

func (*Server) Start

func (s *Server) Start() (*grpc.Server, error)

Start starts the Server on given ip and port.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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