network

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

Index

Constants

View Source
const (
	RequestTypeHonorNode ReqTypesFlag = iota + 1
	RequestTypeNotHonorNode
	RequestTypeStopNetwork
	RequestTypeConfirmation
	RequestTypeBlockCollection
	RequestTypeMaxBlock
	RequestTypeVoting
	RequestSyncMatchineState

	// BlocksPerRequest contains count of blocks per request
	BlocksPerRequest int = 10
)

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 BroadcastNodeConnInfoRequest

type BroadcastNodeConnInfoRequest struct {
	Data []byte
}

func (*BroadcastNodeConnInfoRequest) Read

func (*BroadcastNodeConnInfoRequest) Write

type BroadcastNodeConnInfoResponse

type BroadcastNodeConnInfoResponse struct {
	Data []byte
}

func (*BroadcastNodeConnInfoResponse) Read

func (*BroadcastNodeConnInfoResponse) Write

type CandidateNodeVotingRequest

type CandidateNodeVotingRequest struct {
	Data []byte
}

func (*CandidateNodeVotingRequest) Read

func (*CandidateNodeVotingRequest) Write

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

type CandidateNodeVotingResponse

type CandidateNodeVotingResponse struct {
	Data []byte
}

func (*CandidateNodeVotingResponse) Read

func (*CandidateNodeVotingResponse) Write

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

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

type ReqTypesFlag uint16

type RequestType

type RequestType struct {
	Type ReqTypesFlag
}

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

type VoteMsg

type VoteMsg struct {
	CurrentBlockHeight int64  `json:"currentBlockHeight"`
	LocalAddress       string `json:"localAddress"`
	TcpAddress         string `json:"tcpAddress"`
	EcosystemID        int64  `json:"ecosystemID"`
	Hash               []byte `json:"hash"`
	Agree              bool   `json:"agree"`
	Msg                string `json:"msg"`
	Time               int64  `json:"time"`
	Sign               []byte `json:"sign"`
}

func (*VoteMsg) VerifyVoteForSign

func (voteMsg *VoteMsg) VerifyVoteForSign() string

func (*VoteMsg) VoteForSign

func (voteMsg *VoteMsg) VoteForSign() string

Directories

Path Synopsis
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

Jump to

Keyboard shortcuts

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