network

package
v0.0.0-...-8e17a21 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: GPL-2.0 Imports: 8 Imported by: 12

Documentation

Index

Constants

View Source
const (
	RequestTypeFullNode        = 1
	RequestTypeNotFullNode     = 2
	RequestTypeStopNetwork     = 3
	RequestTypeConfirmation    = 4
	RequestTypeBlockCollection = 7
	RequestTypeMaxBlock        = 10

	// BlocksPerRequest contains count of blocks per request
	BlocksPerRequest int32 = 1000

	MaxBlockSize = 10485760
)

Types of requests

Variables

View Source
var ErrMaxSize = errors.New("Size greater than max size")
View Source
var ErrNotAccepted = errors.New("Not accepted")

Functions

func ReadInt

func ReadInt(r io.Reader) (int64, error)

func ReadSlice

func ReadSlice(r io.Reader) ([]byte, error)

func ReadSliceWithMaxSize

func ReadSliceWithMaxSize(r io.Reader, maxSize uint64) ([]byte, error)

func SendRequestType

func SendRequestType(reqType int64, w io.Writer) error

func WriteInt

func WriteInt(value int64, w io.Writer) error

Types

type ConfirmRequest

type ConfirmRequest struct {
	BlockID uint32
}

ConfirmRequest contains request data

func (*ConfirmRequest) Read

func (req *ConfirmRequest) Read(r io.Reader) error

func (*ConfirmRequest) Write

func (req *ConfirmRequest) Write(w io.Writer) error

type ConfirmResponse

type ConfirmResponse struct {
	// ConfType uint8
	Hash []byte `size:"32"`
}

ConfirmResponse contains response data

func (*ConfirmResponse) Read

func (resp *ConfirmResponse) Read(r io.Reader) error

func (*ConfirmResponse) Write

func (resp *ConfirmResponse) Write(w io.Writer) error

type DisHashResponse

type DisHashResponse struct {
	Data []byte
}

DisHashResponse contains response data

func (*DisHashResponse) Read

func (resp *DisHashResponse) Read(r io.Reader) error

func (*DisHashResponse) Write

func (resp *DisHashResponse) Write(w io.Writer) error

type DisRequest

type DisRequest struct {
	Data []byte
}

DisRequest contains request data

func (*DisRequest) Read

func (req *DisRequest) Read(r io.Reader) error

func (*DisRequest) Write

func (req *DisRequest) Write(w io.Writer) error

type DisTrResponse

type DisTrResponse struct{}

DisTrResponse contains response data

type GetBodiesRequest

type GetBodiesRequest struct {
	BlockID      uint32
	ReverseOrder bool
}

GetBodiesRequest contains BlockID

func (*GetBodiesRequest) Read

func (req *GetBodiesRequest) Read(r io.Reader) error

func (*GetBodiesRequest) Write

func (req *GetBodiesRequest) Write(w io.Writer) error

type GetBodyResponse

type GetBodyResponse struct {
	Data []byte
}

GetBodyResponse is Data []bytes

func (*GetBodyResponse) Read

func (resp *GetBodyResponse) Read(r io.Reader) error

func (*GetBodyResponse) Write

func (resp *GetBodyResponse) Write(w io.Writer) error

type MaxBlockRequest

type MaxBlockRequest struct{}

MaxBlockRequest is max block request

type MaxBlockResponse

type MaxBlockResponse struct {
	BlockID int64
}

MaxBlockResponse is max block response

func (*MaxBlockResponse) Read

func (resp *MaxBlockResponse) Read(r io.Reader) error

func (*MaxBlockResponse) Write

func (resp *MaxBlockResponse) Write(w io.Writer) error

type RequestType

type RequestType struct {
	Type uint16
}

RequestType is type of request

func (*RequestType) Read

func (rt *RequestType) Read(r io.Reader) error

Read read first 2 bytes to uint16

func (*RequestType) Write

func (rt *RequestType) Write(w io.Writer) error

type SelfReaderWriter

type SelfReaderWriter interface {
	Read(io.Reader) error
	Write(io.Writer) error
}

SelfReaderWriter read from Reader to himself and write to io.Writer from himself

type StopNetworkRequest

type StopNetworkRequest struct {
	Data []byte
}

func (*StopNetworkRequest) Read

func (req *StopNetworkRequest) Read(r io.Reader) error

func (*StopNetworkRequest) Write

func (req *StopNetworkRequest) Write(w io.Writer) error

type StopNetworkResponse

type StopNetworkResponse struct {
	Hash []byte
}

func (*StopNetworkResponse) Read

func (resp *StopNetworkResponse) Read(r io.Reader) error

func (*StopNetworkResponse) Write

func (resp *StopNetworkResponse) Write(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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