network

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: GPL-3.0 Imports: 22 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

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

func (*ConfirmMap) Exist

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

func (*ConfirmMap) Store added in v0.3.3

func (m *ConfirmMap) Store(key crypto.Hash, ts time.Time)

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) (*Peer, error)

func (*Peer) ConfirmSnapshotForPeer

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

func (*Peer) ConfirmTransactionForPeer added in v0.2.12

func (me *Peer) ConfirmTransactionForPeer(idForNetwork crypto.Hash, ver *common.VersionedTransaction)

func (*Peer) ListenNeighbors

func (me *Peer) ListenNeighbors() error

func (*Peer) SendHigh

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

func (*Peer) SendNormal

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

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

func (*Peer) SendTransactionMessage

func (me *Peer) SendTransactionMessage(idForNetwork crypto.Hash, ver *common.VersionedTransaction) 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.VersionedTransaction
	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 {
	GetCacheStore() *fastcache.Cache
	BuildAuthenticationMessage() []byte
	Authenticate(msg []byte) (crypto.Hash, string, error)
	BuildGraph() []*SyncPoint
	VerifyAndQueueAppendSnapshot(peerId crypto.Hash, s *common.Snapshot) error
	SendTransactionToPeer(peerId, tx crypto.Hash) error
	CachePutTransaction(peerId crypto.Hash, ver *common.VersionedTransaction) 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

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

func (*TcpClient) Close

func (c *TcpClient) Close() error

func (*TcpClient) Receive

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

func (*TcpClient) Send

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

type TcpTransport

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

func NewTcpClient

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

func NewTcpServer

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

func (*TcpTransport) Accept

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

func (*TcpTransport) Dial

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

func (*TcpTransport) Listen

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