Documentation ¶
Index ¶
- Constants
- type BlockByHeightReqHandler
- type BlockReqHandler
- type ChatMessage
- type ChatRoom
- type Host
- func (host *Host) Close()
- func (host *Host) ConnectPeer(peer *Peer)
- func (host *Host) JoinChatRoom() error
- func (host *Host) RoleStore() RoleStore
- func (host *Host) SetLeader(idx int)
- func (host *Host) SetRoleStore(roleStore RoleStore)
- func (host *Host) SubscribePointMsg() *emitter.Subscription
- func (host *Host) SubscribeTopicMsg() *emitter.Subscription
- type MsgService
- func (svc *MsgService) BroadcastProposal(blk *core.Block) error
- func (svc *MsgService) BroadcastQC(qc *core.QuorumCert) error
- func (svc *MsgService) BroadcastTxList(txList *core.TxList) error
- func (svc *MsgService) RequestBlock(pubKey *core.PublicKey, hash []byte) (*core.Block, error)
- func (svc *MsgService) RequestBlockByHeight(pubKey *core.PublicKey, height uint64) (*core.Block, error)
- func (svc *MsgService) RequestQC(pubKey *core.PublicKey, blkHash []byte) (*core.QuorumCert, error)
- func (svc *MsgService) RequestTxList(pubKey *core.PublicKey, hashes [][]byte) (*core.TxList, error)
- func (svc *MsgService) SendQC(pubKey *core.PublicKey, qc *core.QuorumCert) error
- func (svc *MsgService) SendVote(pubKey *core.PublicKey, vote *core.Vote) error
- func (svc *MsgService) SetReqHandler(reqHandler ReqHandler) error
- func (svc *MsgService) SubscribeProposal(buffer int) *emitter.Subscription
- func (svc *MsgService) SubscribeQC(buffer int) *emitter.Subscription
- func (svc *MsgService) SubscribeTxList(buffer int) *emitter.Subscription
- func (svc *MsgService) SubscribeVote(buffer int) *emitter.Subscription
- type MsgType
- type Peer
- type PeerStatus
- type PeerStore
- func (s *PeerStore) Delete(pubKey *core.PublicKey) *Peer
- func (s *PeerStore) IsValidID(id peer.ID) bool
- func (s *PeerStore) Load(pubKey *core.PublicKey) *Peer
- func (s *PeerStore) LoadOrStore(p *Peer) (actual *Peer, loaded bool)
- func (s *PeerStore) Store(p *Peer) *Peer
- func (s *PeerStore) StoredPeers() []*Peer
- type PointMsg
- type QCReqHandler
- type ReqHandler
- type RoleStore
- type TxListReqHandler
Constants ¶
View Source
const DiscoveryServiceTag = "chatroom"
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 ¶
func (*BlockByHeightReqHandler) HandleReq ¶
func (hdlr *BlockByHeightReqHandler) HandleReq(data []byte) ([]byte, error)
func (*BlockByHeightReqHandler) Type ¶
func (hdlr *BlockByHeightReqHandler) Type() pb.Request_Type
type BlockReqHandler ¶
func (*BlockReqHandler) HandleReq ¶
func (hdlr *BlockReqHandler) HandleReq(data []byte) ([]byte, error)
func (*BlockReqHandler) Type ¶
func (hdlr *BlockReqHandler) Type() pb.Request_Type
type ChatMessage ¶
type ChatMessage []byte
type ChatRoom ¶
type ChatRoom struct {
// contains filtered or unexported fields
}
ChatRoom represents a subscription to a single PubSub topic. Messages can be published to the topic with ChatRoom.Publish, and received messages are pushed to the emitter.Emitter.
func JoinChatRoom ¶
JoinChatRoom tries to subscribe to the PubSub topic, returning a ChatRoom on success.
func (*ChatRoom) Publish ¶
func (cr *ChatRoom) Publish(message ChatMessage) error
Publish sends a message to the pubsub topic.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
func NewHost ¶
func NewHost(privKey *core.PrivateKey, pointAddr, topicAddr multiaddr.Multiaddr) (*Host, error)
func (*Host) ConnectPeer ¶
func (*Host) JoinChatRoom ¶
func (*Host) SetRoleStore ¶
func (*Host) SubscribePointMsg ¶
func (host *Host) SubscribePointMsg() *emitter.Subscription
func (*Host) SubscribeTopicMsg ¶
func (host *Host) SubscribeTopicMsg() *emitter.Subscription
type MsgService ¶
type MsgService struct {
// contains filtered or unexported fields
}
func NewMsgService ¶
func NewMsgService(host *Host) *MsgService
func (*MsgService) BroadcastProposal ¶
func (svc *MsgService) BroadcastProposal(blk *core.Block) error
func (*MsgService) BroadcastQC ¶
func (svc *MsgService) BroadcastQC(qc *core.QuorumCert) error
func (*MsgService) BroadcastTxList ¶
func (svc *MsgService) BroadcastTxList(txList *core.TxList) error
func (*MsgService) RequestBlock ¶
func (*MsgService) RequestBlockByHeight ¶
func (*MsgService) RequestQC ¶
func (svc *MsgService) RequestQC(pubKey *core.PublicKey, blkHash []byte) (*core.QuorumCert, error)
func (*MsgService) RequestTxList ¶
func (*MsgService) SendQC ¶
func (svc *MsgService) SendQC(pubKey *core.PublicKey, qc *core.QuorumCert) error
func (*MsgService) SetReqHandler ¶
func (svc *MsgService) SetReqHandler(reqHandler ReqHandler) error
func (*MsgService) SubscribeProposal ¶
func (svc *MsgService) SubscribeProposal(buffer int) *emitter.Subscription
func (*MsgService) SubscribeQC ¶
func (svc *MsgService) SubscribeQC(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 MsgTypeQC MsgTypeTxList MsgTypeRequest MsgTypeResponse )
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer type
func (*Peer) PointAddr ¶
func (p *Peer) PointAddr() multiaddr.Multiaddr
PointAddr return point address of peer
func (*Peer) Status ¶
func (p *Peer) Status() PeerStatus
type PeerStatus ¶
type PeerStatus int8
PeerStatus type
const ( PeerStatusDisconnected PeerStatus = iota PeerStatusConnecting PeerStatusConnected )
PeerStatus
type PeerStore ¶
type PeerStore struct {
// contains filtered or unexported fields
}
func NewPeerStore ¶
func (*PeerStore) LoadOrStore ¶
func (*PeerStore) StoredPeers ¶
type QCReqHandler ¶
type QCReqHandler struct {
GetQC func(blkHash []byte) (*core.QuorumCert, error)
}
func (*QCReqHandler) Type ¶
func (hdlr *QCReqHandler) Type() pb.Request_Type
type ReqHandler ¶
type ReqHandler interface { Type() pb.Request_Type HandleReq(data []byte) ([]byte, error) }
type TxListReqHandler ¶
func (*TxListReqHandler) HandleReq ¶
func (hdlr *TxListReqHandler) HandleReq(data []byte) ([]byte, error)
func (*TxListReqHandler) Type ¶
func (hdlr *TxListReqHandler) Type() pb.Request_Type
Click to show internal directories.
Click to hide internal directories.