upstream

package
v0.11.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: ISC Imports: 15 Imported by: 0

Documentation

Overview

Package upstream - maintain REQ/REP connection to clients this allow for push of blocks, transactions... as well as polling for out of sync conditions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Upstream

type Upstream struct {
	sync.RWMutex

	UpstreamIntf
	// contains filtered or unexported fields
}

Upstream - structure to hold an upstream connection

func (*Upstream) ActiveInPastSeconds added in v0.11.0

func (u *Upstream) ActiveInPastSeconds(sec time.Duration) bool

ActiveInPastSeconds - active upstream in past seconds

func (*Upstream) CachedRemoteDigestOfLocalHeight added in v0.11.0

func (u *Upstream) CachedRemoteDigestOfLocalHeight() blockdigest.Digest

CachedRemoteDigestOfLocalHeight - cached remote digest of local block height

func (*Upstream) CachedRemoteHeight added in v0.11.0

func (u *Upstream) CachedRemoteHeight() uint64

CachedRemoteHeight - cached remote client height

func (*Upstream) Client added in v0.11.0

func (u *Upstream) Client() zmqutil.ClientIntf

Client - zmq client

func (*Upstream) Connect

func (u *Upstream) Connect(address *util.Connection, serverPublicKey []byte) error

Connect - connect (or reconnect) to a specific server

func (*Upstream) ConnectedTo

func (u *Upstream) ConnectedTo() *zmqutil.Connected

ConnectedTo - if registered return the connection data

func (*Upstream) Destroy

func (u *Upstream) Destroy()

Destroy - shutdown a connection and terminate its background processes

func (*Upstream) GetBlockData

func (u *Upstream) GetBlockData(blockNumber uint64) ([]byte, error)

GetBlockData - fetch block data from a specific block number

func (*Upstream) IsConnected added in v0.11.0

func (u *Upstream) IsConnected() bool

IsConnected - check if registered and have a valid connection

func (*Upstream) IsConnectedTo

func (u *Upstream) IsConnectedTo(serverPublicKey []byte) bool

IsConnectedTo - check the current destination

does not mean actually connected, as could be in a timeout and reconnect state

func (*Upstream) LocalHeight added in v0.11.0

func (u *Upstream) LocalHeight() uint64

LocalHeight - local block height

func (*Upstream) Name added in v0.11.0

func (u *Upstream) Name() string

Name - upstream name

func (*Upstream) RemoteAddr added in v0.11.0

func (u *Upstream) RemoteAddr() (string, error)

RemoteAddr - remote client address

func (*Upstream) RemoteDigestOfHeight added in v0.11.0

func (u *Upstream) RemoteDigestOfHeight(blockNumber uint64) (blockdigest.Digest, error)

RemoteDigestOfHeight - fetch block digest from a specific block number

func (*Upstream) RemoteHeight added in v0.11.0

func (u *Upstream) RemoteHeight() (uint64, error)

must have lock held before calling

func (*Upstream) ResetServer added in v0.10.2

func (u *Upstream) ResetServer()

ResetServer - clear Server side info of Zmq client for reusing the upstream

func (*Upstream) ServerPublicKey added in v0.11.0

func (u *Upstream) ServerPublicKey() []byte

ServerPublicKey - return the internal ZeroMQ client data

type UpstreamIntf added in v0.11.0

type UpstreamIntf interface {
	ActiveInPastSeconds(time.Duration) bool
	CachedRemoteDigestOfLocalHeight() blockdigest.Digest
	CachedRemoteHeight() uint64
	Client() zmqutil.ClientIntf
	Connect(*util.Connection, []byte) error
	ConnectedTo() *zmqutil.Connected
	Destroy()
	GetBlockData(uint64) ([]byte, error)
	IsConnectedTo([]byte) bool
	IsConnected() bool
	LocalHeight() uint64
	Name() string
	RemoteAddr() (string, error)
	RemoteDigestOfHeight(uint64) (blockdigest.Digest, error)
	RemoteHeight() (uint64, error)
	ResetServer()
	ServerPublicKey() []byte
}

func New

func New(privateKey []byte, publicKey []byte, timeout time.Duration) (UpstreamIntf, error)

New - create a connection to an upstream server

Jump to

Keyboard shortcuts

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