net

package
v0.0.0-...-42a6357 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inv

type Inv struct {
	// contains filtered or unexported fields
}

Inv structure

func (*Inv) Hash

func (i *Inv) Hash() [32]byte

Hash returns inventory hash

func (*Inv) Object

func (i *Inv) Object() string

Object returns inventory object

func (*Inv) Payload

func (i *Inv) Payload() []byte

Payload returns inventory payload

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message holds components of a network message

func (*Message) Cmd

func (m *Message) Cmd() string

Cmd returns cmd

func (*Message) Length

func (m *Message) Length() uint32

Length returns length

func (*Message) Payload

func (m *Message) Payload() []byte

Payload returns payload

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network holds information about the network status

func (*Network) AddPeer

func (n *Network) AddPeer(p *Peer) error

AddPeer adds a new peer

func (*Network) ConnectedPeers

func (n *Network) ConnectedPeers() []string

ConnectedPeers returns the number of connected peers

func (*Network) New

func (n *Network) New(fn apply)

New initializes network structure

func (*Network) SetContext

func (n *Network) SetContext(ctx *zmq.Context)

SetContext sets network context

func (*Network) SetMaxPeers

func (n *Network) SetMaxPeers(m uint32)

SetMaxPeers sets the maximum number of peers

func (*Network) Watch

func (n *Network) Watch(url string)

Watch network and adds new peers

type Peer

type Peer struct {
	Pub *zmq.Socket
	// contains filtered or unexported fields
}

Peer holds information about connected peer

func NewPeer

func NewPeer(ip string, port uint16) *Peer

NewPeer initializes peer structure

func (*Peer) GetIP

func (p *Peer) GetIP() string

GetIP returns IP of connected peer

func (*Peer) HandleInv

func (p *Peer) HandleInv(payload []byte) error

HandleInv parse inventories

func (*Peer) HandleObject

func (p *Peer) HandleObject(object string, payload []byte) (*Inv, error)

HandleObject manages and saves tx and block messages

func (*Peer) HandleReject

func (p *Peer) HandleReject(payload []byte)

HandleReject prints reject error message

func (*Peer) HandleVersion

func (p *Peer) HandleVersion(payload []byte) error

HandleVersion handles version message

func (*Peer) SendHeaders

func (p *Peer) SendHeaders() error

SendHeaders send a sendheaders message to connected peer

func (*Peer) SendPing

func (p *Peer) SendPing() error

SendPing sends a ping message

func (*Peer) SendPong

func (p *Peer) SendPong(nonce []byte) error

SendPong sends a pong message to conneted peer

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue is a basic FIFO queue based on a circular list that resizes as needed.

func NewQueue

func NewQueue(size int) *Queue

NewQueue returns a new queue with the given initial size.

func (*Queue) Exists

func (q *Queue) Exists(hash [32]byte) bool

Exists test if element already exists in queue or not

func (*Queue) Pop

func (q *Queue) Pop() error

Pop removes and returns a node from the queue in first to last order

func (*Queue) Push

func (q *Queue) Push(hash [32]byte, inventory *Inv) error

Push adds a node to the queue

func (*Queue) Update

func (q *Queue) Update(hash [32]byte, inventory *Inv) error

Update inventory of corresponding hash

Jump to

Keyboard shortcuts

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