network

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PeerMessageTypeSnapshot           = 0
	PeerMessageTypePing               = 1
	PeerMessageTypeAuthentication     = 3
	PeerMessageTypeGraph              = 4
	PeerMessageTypeSnapshotConfirm    = 5
	PeerMessageTypeTransactionRequest = 6
	PeerMessageTypeTransaction        = 7
)
View Source
const (
	MaxIncomingStreams = 128
	HandshakeTimeout   = 10 * time.Second
	IdleTimeout        = 60 * time.Second
	ReadDeadline       = 10 * time.Second
	WriteDeadline      = 10 * time.Second
)
View Source
const (
	TransportMessageVersion    = 1
	TransportMessageMaxSize    = 32 * 1024 * 1024
	TransportMessageHeaderSize = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanMsg

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

type Client

type Client interface {
	Receive() ([]byte, error)
	Send([]byte) error
	Close() error
}

type ConfirmMap added in v0.1.0

type ConfirmMap struct {
	sync.Map
}

func (*ConfirmMap) Exist added in v0.1.0

func (m *ConfirmMap) Exist(key crypto.Hash, duration time.Duration) bool

type Peer

type Peer struct {
	IdForNetwork crypto.Hash
	Address      string
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(handle SyncHandle, idForNetwork crypto.Hash, addr string) *Peer

func (*Peer) AddNeighbor

func (me *Peer) AddNeighbor(idForNetwork crypto.Hash, addr string)

func (*Peer) ConfirmSnapshotForPeer

func (me *Peer) ConfirmSnapshotForPeer(idForNetwork, snap crypto.Hash, finalized byte)

func (*Peer) ListenNeighbors

func (me *Peer) ListenNeighbors() error

func (*Peer) SendHigh added in v0.1.0

func (p *Peer) SendHigh(key crypto.Hash, data []byte) error

func (*Peer) SendNormal added in v0.1.0

func (p *Peer) SendNormal(key crypto.Hash, data []byte) error

func (*Peer) SendSnapshotConfirmMessage

func (me *Peer) SendSnapshotConfirmMessage(idForNetwork crypto.Hash, snap crypto.Hash, finalized byte) error

func (*Peer) SendSnapshotMessage added in v0.1.0

func (me *Peer) SendSnapshotMessage(idForNetwork crypto.Hash, s *common.Snapshot, finalized byte) error

func (*Peer) SendTransactionMessage

func (me *Peer) SendTransactionMessage(idForNetwork crypto.Hash, tx *common.SignedTransaction) error

func (*Peer) SendTransactionRequestMessage

func (me *Peer) SendTransactionRequestMessage(idForNetwork crypto.Hash, tx crypto.Hash) error

type PeerMessage

type PeerMessage struct {
	Type            uint8
	Snapshot        *common.Snapshot
	SnapshotHash    crypto.Hash
	Finalized       byte
	Transaction     *common.SignedTransaction
	TransactionHash crypto.Hash
	FinalCache      []*SyncPoint
	Data            []byte
}

type QuicClient

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

func (*QuicClient) Close

func (c *QuicClient) Close() error

func (*QuicClient) Receive

func (c *QuicClient) Receive() ([]byte, error)

func (*QuicClient) Send

func (c *QuicClient) Send(data []byte) error

type QuicTransport

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

func NewQuicClient

func NewQuicClient(addr string) (*QuicTransport, error)

func NewQuicServer

func NewQuicServer(addr string) (*QuicTransport, error)

func (*QuicTransport) Accept

func (t *QuicTransport) Accept() (Client, error)

func (*QuicTransport) Dial

func (t *QuicTransport) Dial() (Client, error)

func (*QuicTransport) Listen

func (t *QuicTransport) Listen() error

type SyncHandle

type SyncHandle interface {
	BuildAuthenticationMessage() []byte
	Authenticate(msg []byte) (crypto.Hash, error)
	BuildGraph() []*SyncPoint
	QueueAppendSnapshot(peerId crypto.Hash, s *common.Snapshot) error
	SendTransactionToPeer(peerId, tx crypto.Hash) error
	CachePutTransaction(tx *common.SignedTransaction) error
	ReadSnapshotsSinceTopology(offset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
	ReadSnapshotsForNodeRound(nodeIdWithNetwork crypto.Hash, round uint64) ([]*common.SnapshotWithTopologicalOrder, error)
	UpdateSyncPoint(peerId crypto.Hash, points []*SyncPoint)
}

type SyncPoint

type SyncPoint struct {
	NodeId crypto.Hash
	Number uint64
	Hash   crypto.Hash
}

type TcpClient added in v0.1.0

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

func (*TcpClient) Close added in v0.1.0

func (c *TcpClient) Close() error

func (*TcpClient) Receive added in v0.1.0

func (c *TcpClient) Receive() ([]byte, error)

func (*TcpClient) Send added in v0.1.0

func (c *TcpClient) Send(data []byte) error

type TcpTransport added in v0.1.0

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

func NewTcpClient added in v0.1.0

func NewTcpClient(addr string) (*TcpTransport, error)

func NewTcpServer added in v0.1.0

func NewTcpServer(addr string) (*TcpTransport, error)

func (*TcpTransport) Accept added in v0.1.0

func (t *TcpTransport) Accept() (Client, error)

func (*TcpTransport) Dial added in v0.1.0

func (t *TcpTransport) Dial() (Client, error)

func (*TcpTransport) Listen added in v0.1.0

func (t *TcpTransport) Listen() error

type Transport

type Transport interface {
	Listen() error
	Dial() (Client, error)
	Accept() (Client, error)
}

type TransportMessage

type TransportMessage struct {
	Version uint8
	Size    uint32
	Data    []byte
}

type UnixClient added in v0.1.4

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

func (*UnixClient) Close added in v0.1.4

func (c *UnixClient) Close() error

func (*UnixClient) Receive added in v0.1.4

func (c *UnixClient) Receive() ([]byte, error)

func (*UnixClient) Send added in v0.1.4

func (c *UnixClient) Send(data []byte) error

type UnixTransport added in v0.1.4

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

func NewUnixClient added in v0.1.4

func NewUnixClient(addr string) (*UnixTransport, error)

func NewUnixServer added in v0.1.4

func NewUnixServer(addr string) (*UnixTransport, error)

func (*UnixTransport) Accept added in v0.1.4

func (t *UnixTransport) Accept() (Client, error)

func (*UnixTransport) Dial added in v0.1.4

func (t *UnixTransport) Dial() (Client, error)

func (*UnixTransport) Listen added in v0.1.4

func (t *UnixTransport) Listen() error

Jump to

Keyboard shortcuts

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