p2p

package
v0.0.0-...-169a2f2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// message size limit in bytes (~100 MB)
	// to avoid out of memory allocation for reading next message
	MessageSizeLimit uint32 = 100000000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockByHeightReqHandler

type BlockByHeightReqHandler struct {
	GetBlockByHeight func(height uint64) (*core.Block, error)
}

func (*BlockByHeightReqHandler) HandleReq

func (hdlr *BlockByHeightReqHandler) HandleReq(sender *core.PublicKey, data []byte) ([]byte, error)

func (*BlockByHeightReqHandler) Type

type BlockReqHandler

type BlockReqHandler struct {
	GetBlock func(hash []byte) (*core.Block, error)
}

func (*BlockReqHandler) HandleReq

func (hdlr *BlockReqHandler) HandleReq(sender *core.PublicKey, data []byte) ([]byte, error)

func (*BlockReqHandler) Type

func (hdlr *BlockReqHandler) Type() p2p_pb.Request_Type

type Host

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

func NewHost

func NewHost(privKey *core.PrivateKey, localAddr multiaddr.Multiaddr) (*Host, error)

func (*Host) AddPeer

func (host *Host) AddPeer(peer *Peer)

func (*Host) PeerStore

func (host *Host) PeerStore() *PeerStore

type MsgService

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

func NewMsgService

func NewMsgService(host *Host) *MsgService

func (*MsgService) BroadcastNewView

func (svc *MsgService) BroadcastNewView(qc *core.QuorumCert) error

func (*MsgService) BroadcastProposal

func (svc *MsgService) BroadcastProposal(blk *core.Block) error

func (*MsgService) BroadcastTxList

func (svc *MsgService) BroadcastTxList(txList *core.TxList) error

func (*MsgService) RequestBlock

func (svc *MsgService) RequestBlock(pubKey *core.PublicKey, hash []byte) (*core.Block, error)

func (*MsgService) RequestBlockByHeight

func (svc *MsgService) RequestBlockByHeight(
	pubKey *core.PublicKey, height uint64,
) (*core.Block, error)

func (*MsgService) RequestTxList

func (svc *MsgService) RequestTxList(pubKey *core.PublicKey, hashes [][]byte) (*core.TxList, error)

func (*MsgService) SendNewView

func (svc *MsgService) SendNewView(pubKey *core.PublicKey, qc *core.QuorumCert) error

func (*MsgService) SendVote

func (svc *MsgService) SendVote(pubKey *core.PublicKey, vote *core.Vote) error

func (*MsgService) SetReqHandler

func (svc *MsgService) SetReqHandler(reqHandler ReqHandler) error

func (*MsgService) SubscribeNewView

func (svc *MsgService) SubscribeNewView(buffer int) *emitter.Subscription

func (*MsgService) SubscribeProposal

func (svc *MsgService) SubscribeProposal(buffer int) *emitter.Subscription

func (*MsgService) SubscribeTxList

func (svc *MsgService) SubscribeTxList(buffer int) *emitter.Subscription

func (*MsgService) SubscribeVote

func (svc *MsgService) SubscribeVote(buffer int) *emitter.Subscription

type MsgType

type MsgType byte
const (
	MsgTypeProposal MsgType
	MsgTypeVote
	MsgTypeNewView
	MsgTypeTxList
	MsgTypeRequest
	MsgTypeResponse
)

type Peer

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

Peer type

func NewPeer

func NewPeer(pubKey *core.PublicKey, addr multiaddr.Multiaddr) *Peer

NewPeer godoc

func (*Peer) Addr

func (p *Peer) Addr() multiaddr.Multiaddr

Addr return network address of peer

func (*Peer) PublicKey

func (p *Peer) PublicKey() *core.PublicKey

PublicKey returns public key of peer

func (*Peer) Status

func (p *Peer) Status() PeerStatus

Status gogoc

func (*Peer) SubscribeMsg

func (p *Peer) SubscribeMsg() *emitter.Subscription

SubscribeMsg gogoc

func (*Peer) WriteMsg

func (p *Peer) WriteMsg(msg []byte) error

WriteMsg gogoc

type PeerStatus

type PeerStatus int8

PeerStatus type

const (
	PeerStatusDisconnected PeerStatus = iota
	PeerStatusConnecting
	PeerStatusConnected
	PeerStatusBlocked
)

PeerStatus

type PeerStore

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

func NewPeerStore

func NewPeerStore() *PeerStore

func (*PeerStore) Delete

func (s *PeerStore) Delete(pubKey *core.PublicKey) *Peer

func (*PeerStore) List

func (s *PeerStore) List() []*Peer

func (*PeerStore) Load

func (s *PeerStore) Load(pubKey *core.PublicKey) *Peer

func (*PeerStore) LoadOrStore

func (s *PeerStore) LoadOrStore(p *Peer) (actual *Peer, loaded bool)

func (*PeerStore) Store

func (s *PeerStore) Store(p *Peer) *Peer

type ReqHandler

type ReqHandler interface {
	Type() p2p_pb.Request_Type
	HandleReq(sender *core.PublicKey, data []byte) ([]byte, error)
}

type TxListReqHandler

type TxListReqHandler struct {
	GetTxList func(hashes [][]byte) (*core.TxList, error)
}

func (*TxListReqHandler) HandleReq

func (hdlr *TxListReqHandler) HandleReq(sender *core.PublicKey, data []byte) ([]byte, error)

func (*TxListReqHandler) Type

func (hdlr *TxListReqHandler) Type() p2p_pb.Request_Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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