server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBatch added in v0.2.0

func NewBatch(batch []crypto.Signature) (*blockBatch, error)

Types

type NodeState added in v0.2.0

type NodeState struct {
	State          string           `json:"state"`
	Addr           string           `json:"addr"`
	LastKnownBlock crypto.Signature `json:"last_known_block"`
	KnownVersion   proto.Version    `json:"known_versoin"`
}

type Option added in v0.2.0

type Option func(*Server) error

func WithDeclaredAddr added in v0.2.0

func WithDeclaredAddr(addr string) Option

func WithGenesis added in v0.2.0

func WithGenesis(gen string) Option

func WithLevelDBPath added in v0.2.0

func WithLevelDBPath(dbpath string) Option

func WithPeers added in v0.2.0

func WithPeers(peers []string) Option

func WithRestAddr added in v0.2.0

func WithRestAddr(addr string) Option

type Peer added in v0.2.0

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

Peer manages all the connection logic with a single peer

It may be used in a two ways: as a client connection and as a server connection

When using as a client connection it should be created with a remote peer addr specified. In that case it will attempt to dial this addr and then continue processing with a dialed connection

When using as a server connection, it is created with an existing *p2p.Conn that was previously accepted on a listening server

func NewPeer added in v0.2.0

func NewPeer(gen crypto.Signature, db *db.WavesDB, opts ...PeerOption) (*Peer, error)

NewPeer creates a new peer

func (*Peer) State added in v0.2.0

func (p *Peer) State() NodeState

func (*Peer) Stop added in v0.2.0

func (p *Peer) Stop()

Stop stops the processing of connection with peer

type PeerOption added in v0.2.0

type PeerOption func(*Peer) error

PeerOption is a creating option for creating Peer

func WithAddr added in v0.2.0

func WithAddr(addr string) PeerOption

WithAddr configures peer to have an addr

func WithConn added in v0.2.0

func WithConn(conn net.Conn) PeerOption

WithConn configures peer with an existing connection

func WithDeclAddr added in v0.2.0

func WithDeclAddr(addr string) PeerOption

func WithPeersChan added in v0.2.0

func WithPeersChan(c chan proto.PeerInfo) PeerOption

WithPeersChan configures peer with a channel to send peer infos to

type Server

type Server struct {
	BootPeerAddrs []string
	Listen        string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...Option) (*Server, error)

func (*Server) Run

func (s *Server) Run(ctx context.Context)

func (*Server) RunClients

func (s *Server) RunClients(ctx context.Context)

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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