Versions in this module Expand all Collapse all v1 v1.1.3 Feb 13, 2020 Changes in this version + const AccountingVersion + const ErrDecode + const ErrHandler + const ErrHandshake + const ErrInvalidMsgCode + const ErrInvalidMsgType + const ErrMsgTooLong + const ErrNoHandler + const ErrWrite + const Receiver + const Sender + type Accounting struct + func NewAccounting(balance Balance, po Prices) *Accounting + func (ah *Accounting) Receive(peer *Peer, size uint32, msg interface{}) error + func (ah *Accounting) Send(peer *Peer, size uint32, msg interface{}) error + type AccountingApi struct + func NewAccountingApi(m *AccountingMetrics) *AccountingApi + func (self *AccountingApi) Balance() (int64, error) + func (self *AccountingApi) BalanceCredit() (int64, error) + func (self *AccountingApi) BalanceDebit() (int64, error) + func (self *AccountingApi) BytesCredit() (int64, error) + func (self *AccountingApi) BytesDebit() (int64, error) + func (self *AccountingApi) MsgCredit() (int64, error) + func (self *AccountingApi) MsgDebit() (int64, error) + func (self *AccountingApi) PeerDrops() (int64, error) + func (self *AccountingApi) SelfDrops() (int64, error) + type AccountingMetrics struct + func NewAccountingMetrics(r metrics.Registry, d time.Duration, path string) *AccountingMetrics + func SetupAccountingMetrics(reportInterval time.Duration, path string) *AccountingMetrics + func (am *AccountingMetrics) Close() + type Balance interface + Add func(amount int64, peer *Peer) error + type Error struct + Code int + func (e Error) Error() (message string) + type Hook interface + Receive func(peer *Peer, size uint32, msg interface{}) error + Send func(peer *Peer, size uint32, msg interface{}) error + type Payer bool + type Peer struct + func NewPeer(p *p2p.Peer, rw p2p.MsgReadWriter, spec *Spec) *Peer + func (p *Peer) Drop() + func (p *Peer) Handshake(ctx context.Context, hs interface{}, verify func(interface{}) error) (interface{}, error) + func (p *Peer) HasCap(capName string) (yes bool) + func (p *Peer) Run(handler func(ctx context.Context, msg interface{}) error) error + func (p *Peer) Send(ctx context.Context, msg interface{}) error + type Price struct + Payer Payer + PerByte bool + Value uint64 + func (p *Price) For(payer Payer, size uint32) int64 + type Prices interface + Price func(interface{}) *Price + type Spec struct + Hook Hook + MaxMsgSize uint32 + Messages []interface{} + Name string + Version uint + func (s *Spec) GetCode(msg interface{}) (uint64, bool) + func (s *Spec) Length() uint64 + func (s *Spec) NewMsg(code uint64) (interface{}, bool) + type WrappedMsg struct + Context []byte + Payload []byte + Size uint32