Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateFieldDescSize(varSize int) int
- func CheckAndGetV1(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, error)
- func CheckProtoCert(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, error)
- func ComparePeerID(pid1, pid2 types.PeerID) int
- func ContainsID(pool []types.PeerID, id types.PeerID) bool
- func ConvertCertToProto(w *p2pcommon.AgentCertificateV1) (*types.AgentCertificate, error)
- func ConvertCertsToProto(cs []*p2pcommon.AgentCertificateV1) ([]*types.AgentCertificate, error)
- func ConvertPKToBTCEC(pk crypto.PrivKey) *btcec.PrivateKey
- func ConvertPKToLibP2P(pk *btcec.PrivateKey) crypto.PrivKey
- func ConvertPubKeyToBTCEC(pk crypto.PubKey) *btcec.PublicKey
- func ConvertPubToLibP2P(pk *btcec.PublicKey) crypto.PubKey
- func DebugLogReceive(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, ...)
- func DebugLogReceiveMsg(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, ...)
- func DebugLogReceiveResponse(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, reqID string, ...)
- func DebugLogReceiveResponseMsg(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, reqID string, ...)
- func ExternalIP() (net.IP, error)
- func ExtractBlockFromRequest(rawResponse interface{}, err error) (*types.Block, error)
- func FromMultiAddr(targetAddr multiaddr.Multiaddr) (p2pcommon.PeerMeta, error)
- func FromMultiAddrString(str string) (p2pcommon.PeerMeta, error)
- func FromMultiAddrStringWithPID(str string, id types.PeerID) (p2pcommon.PeerMeta, error)
- func FromMultiAddrToPeerInfo(ma types.Multiaddr) (p2pcommon.PeerMeta, error)
- func GenerateKeyFile(dir, prefix string) (crypto.PrivKey, crypto.PubKey, error)
- func InvokeWithTimer(m Callable, timer *time.Timer) (interface{}, error)
- func IsContainedIP(ip net.IP, nets []*net.IPNet) bool
- func LoadKeyFile(keyFile string) (crypto.PrivKey, crypto.PubKey, error)
- func MarshalMessageBody(message p2pcommon.MessageBody) ([]byte, error)
- func NewAgentCertV1(bpID, agentID types.PeerID, bpKey *btcec.PrivateKey, addrs []string, ...) (*p2pcommon.AgentCertificateV1, error)
- func PeerMetaToMultiAddr(m p2pcommon.PeerMeta) (types.Multiaddr, error)
- func PrintChainID(id *types.ChainID) string
- func PrintHashList(blocks []*types.Block) string
- func ProtocolIDsToString(sli []core.ProtocolID) string
- func RandomUUID() string
- func ReadToLen(rd io.Reader, bf []byte) (int, error)
- func ShortForm(pid types.PeerID) string
- func ShortMetaForm(m p2pcommon.PeerMeta) string
- func SignCert(key *btcec.PrivateKey, wrap *p2pcommon.AgentCertificateV1) error
- func UnmarshalAndReturn(data []byte, msgData p2pcommon.MessageBody) (p2pcommon.MessageBody, error)
- func UnmarshalMessageBody(data []byte, msgData p2pcommon.MessageBody) error
- func VerifyCert(wrap *p2pcommon.AgentCertificateV1) bool
- type AgentCertMarshaller
- type Callable
- type ChannelPipe
- type LogIPNetMarshaller
- type LogPeerIdsMarshaller
- type LogPeerMetasMarshaller
- type LogPeersMarshaller
- type LogStringersMarshaller
- type LogStringsMarshaller
- type MultiListener
- type PipeEventListener
- type PressableQueue
- func (q *PressableQueue) Empty() bool
- func (q *PressableQueue) Full() bool
- func (q *PressableQueue) Offer(e interface{}) bool
- func (q *PressableQueue) Peek() interface{}
- func (q *PressableQueue) Poll() interface{}
- func (q *PressableQueue) Press(e interface{}) interface{}
- func (q *PressableQueue) Size() int
- type StatListener
Constants ¶
const ( LogPeerID = "peer_id" LogFullID = "full_id" // LogFullID is Full qualified peer id LogPeerName = "peer_nm" LogProtoID = "protocol_id" LogMsgID = "msg_id" LogOrgReqID = "req_id" // LogOrgReqID is msgid of request from remote peer LogBlkHash = types.LogBlkHash LogBlkNo = types.LogBlkNo LogBlkCount = "blk_cnt" LogTxHash = "tx_hash" LogTxCount = "tx_cnt" LogRespStatus = types.LogRespStatus LogRaftMsg = "raftMsg" )
frequently used constants for indicating p2p log category
Variables ¶
var (
UseFullID bool
)
Functions ¶
func CalculateFieldDescSize ¶
func CheckAndGetV1 ¶
func CheckAndGetV1(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, error)
func CheckProtoCert ¶
func CheckProtoCert(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, error)
func ComparePeerID ¶
ComparePeerID do byte-wise compare of two peerIDs,
func ConvertCertToProto ¶
func ConvertCertToProto(w *p2pcommon.AgentCertificateV1) (*types.AgentCertificate, error)
func ConvertCertsToProto ¶
func ConvertCertsToProto(cs []*p2pcommon.AgentCertificateV1) ([]*types.AgentCertificate, error)
func ConvertPKToBTCEC ¶
func ConvertPKToBTCEC(pk crypto.PrivKey) *btcec.PrivateKey
ConvertPKToBTCEC return nil if converison is failed
func ConvertPKToLibP2P ¶
func ConvertPKToLibP2P(pk *btcec.PrivateKey) crypto.PrivKey
ConvertPKToLibP2P return nil if converison is failed
func ConvertPubKeyToBTCEC ¶
ConvertPubKeyToBTCEC return nil if converison is failed
func ConvertPubToLibP2P ¶
ConvertPubToLibP2P return nil if converison is failed
func DebugLogReceive ¶
func DebugLogReceive(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, peer p2pcommon.RemotePeer, additional zerolog.LogObjectMarshaler)
DebugLogReceive log received remote message with debug level.
func DebugLogReceiveMsg ¶
func DebugLogReceiveMsg(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, peer p2pcommon.RemotePeer, additional interface{})
Deprecated
func DebugLogReceiveResponse ¶
func DebugLogReceiveResponse(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, reqID string, peer p2pcommon.RemotePeer, additional zerolog.LogObjectMarshaler)
DebugLogReceive log received remote response message with debug level.
func DebugLogReceiveResponseMsg ¶
func DebugLogReceiveResponseMsg(logger *log.Logger, protocol p2pcommon.SubProtocol, msgID string, reqID string, peer p2pcommon.RemotePeer, additional interface{})
Deprecated
func ExternalIP ¶
func ExtractBlockFromRequest ¶
func FromMultiAddr ¶
FromMultiAddr returns PeerMeta from multiaddr. the multiaddr must contain address(ip or domain name), port and peer id.
func FromMultiAddrStringWithPID ¶
FromMultiAddrStringWithPID
func FromMultiAddrToPeerInfo ¶
FromMultiAddrToPeerInfo create PeerStaticInfo from qualified multiaddr which contains if and only if address, port and peerID
func GenerateKeyFile ¶
func InvokeWithTimer ¶
InvokeWithTimer call DoCall method of m and return if m is finished or return error if timer fires.
func MarshalMessageBody ¶
func MarshalMessageBody(message p2pcommon.MessageBody) ([]byte, error)
func NewAgentCertV1 ¶
func NewAgentCertV1(bpID, agentID types.PeerID, bpKey *btcec.PrivateKey, addrs []string, ttl time.Duration) (*p2pcommon.AgentCertificateV1, error)
NewAgentCertV1 create certificate object
func PeerMetaToMultiAddr ¶
PeerMetaToMultiAddr make libp2p compatible Multiaddr object from peermeta @Deprecated
func PrintChainID ¶
func PrintHashList ¶
func ProtocolIDsToString ¶
func ProtocolIDsToString(sli []core.ProtocolID) string
func RandomUUID ¶
func RandomUUID() string
RandomUUID generate random UUID and return in form of string
func ShortMetaForm ¶
func SignCert ¶
func SignCert(key *btcec.PrivateKey, wrap *p2pcommon.AgentCertificateV1) error
func UnmarshalAndReturn ¶
func UnmarshalAndReturn(data []byte, msgData p2pcommon.MessageBody) (p2pcommon.MessageBody, error)
func UnmarshalMessageBody ¶
func UnmarshalMessageBody(data []byte, msgData p2pcommon.MessageBody) error
func VerifyCert ¶
func VerifyCert(wrap *p2pcommon.AgentCertificateV1) bool
Types ¶
type AgentCertMarshaller ¶
type AgentCertMarshaller struct {
*p2pcommon.AgentCertificateV1
}
func (AgentCertMarshaller) MarshalZerologObject ¶
func (a AgentCertMarshaller) MarshalZerologObject(e *zerolog.Event)
type Callable ¶
type Callable interface { // DoCall run function. it should put result anything if call is over. It also stop function if Cancel was called as soon as possible DoCall(done chan<- interface{}) // Cancel should return instantly Cancel() }
Callable
type ChannelPipe ¶
type ChannelPipe interface { // Put item to pipe. it should be used after Open() method is called. // It always returns true and guaranty that item is queued. Put(item interface{}) bool Out() <-chan interface{} // Done should be called after get item from out channel Done() Open() Close() }
ChannelPipe serve non blocking limited size channel. It preserve input ordering, and not block caller unless it is Closed() Tt must be called Open before using it, and Close for dispose resource.
func NewDefaultChannelPipe ¶
func NewDefaultChannelPipe(bufSize int, listener PipeEventListener) ChannelPipe
NewDefaultChannelPipe create pipe to output channel out
type LogIPNetMarshaller ¶
type LogIPNetMarshaller struct {
// contains filtered or unexported fields
}
func NewLogIPNetMarshaller ¶
func NewLogIPNetMarshaller(arr []*net.IPNet, limit int) *LogIPNetMarshaller
func (LogIPNetMarshaller) MarshalZerologArray ¶
func (m LogIPNetMarshaller) MarshalZerologArray(a *zerolog.Array)
type LogPeerIdsMarshaller ¶
type LogPeerIdsMarshaller struct {
// contains filtered or unexported fields
}
func NewLogPeerIdsMarshaller ¶
func NewLogPeerIdsMarshaller(arr []types.PeerID, limit int) *LogPeerIdsMarshaller
func (LogPeerIdsMarshaller) MarshalZerologArray ¶
func (m LogPeerIdsMarshaller) MarshalZerologArray(a *zerolog.Array)
type LogPeerMetasMarshaller ¶
type LogPeerMetasMarshaller struct {
// contains filtered or unexported fields
}
func NewLogPeerMetasMarshaller ¶
func NewLogPeerMetasMarshaller(metas []p2pcommon.PeerMeta, limit int) *LogPeerMetasMarshaller
func (*LogPeerMetasMarshaller) MarshalZerologArray ¶
func (m *LogPeerMetasMarshaller) MarshalZerologArray(a *zerolog.Array)
type LogPeersMarshaller ¶
type LogPeersMarshaller struct {
// contains filtered or unexported fields
}
func NewLogPeersMarshaller ¶
func NewLogPeersMarshaller(metas []p2pcommon.RemotePeer, limit int) *LogPeersMarshaller
func (*LogPeersMarshaller) MarshalZerologArray ¶
func (m *LogPeersMarshaller) MarshalZerologArray(a *zerolog.Array)
type LogStringersMarshaller ¶
type LogStringersMarshaller struct {
// contains filtered or unexported fields
}
func NewLogStringersMarshaller ¶
func NewLogStringersMarshaller(arr []fmt.Stringer, limit int) *LogStringersMarshaller
func (*LogStringersMarshaller) MarshalZerologArray ¶
func (m *LogStringersMarshaller) MarshalZerologArray(a *zerolog.Array)
type LogStringsMarshaller ¶
type LogStringsMarshaller struct {
// contains filtered or unexported fields
}
func NewLogStringsMarshaller ¶
func NewLogStringsMarshaller(strs []string, limit int) *LogStringsMarshaller
func (*LogStringsMarshaller) MarshalZerologArray ¶
func (m *LogStringsMarshaller) MarshalZerologArray(a *zerolog.Array)
type MultiListener ¶
type MultiListener struct {
// contains filtered or unexported fields
}
MultiListener can contain multiple unit listeners and toss events
func NewMultiListener ¶
func NewMultiListener(ls ...PipeEventListener) *MultiListener
func (*MultiListener) AppendListener ¶
func (ml *MultiListener) AppendListener(l PipeEventListener)
func (*MultiListener) OnDrop ¶
func (ml *MultiListener) OnDrop(element interface{})
func (*MultiListener) OnIn ¶
func (ml *MultiListener) OnIn(element interface{})
func (*MultiListener) OnOut ¶
func (ml *MultiListener) OnOut(element interface{})
type PipeEventListener ¶
type PipeEventListener interface { // OnIn is called when item is queued OnIn(element interface{}) // OnDrop is called when queued item is dropped and not out to channel receiver OnDrop(element interface{}) // OnOut is called when queued item went to out channel (and will be sent to receiver) OnOut(element interface{}) }
PipeEventListener listen event of ChannelPipe
type PressableQueue ¶
type PressableQueue struct {
// contains filtered or unexported fields
}
PressableQueue non-threadsafe fixed size queue, implemented like circular queue
func NewPressableQueue ¶
func NewPressableQueue(capacity int) *PressableQueue
NewPressableQueue create a new queue
func (*PressableQueue) Empty ¶
func (q *PressableQueue) Empty() bool
Empty returns true if queue has no element, or false if not
func (*PressableQueue) Full ¶
func (q *PressableQueue) Full() bool
Full returns true if queue has maximum number of elements, or false if not
func (*PressableQueue) Offer ¶
func (q *PressableQueue) Offer(e interface{}) bool
Offer is adding element to queue, it returns true if add success, or false if queue if add fail.
func (*PressableQueue) Peek ¶
func (q *PressableQueue) Peek() interface{}
Peek return first element but not delete in queue. It returns nil if queue is empty
func (*PressableQueue) Poll ¶
func (q *PressableQueue) Poll() interface{}
Poll return first element and remove it in queue. It returns nil if queue is empty
func (*PressableQueue) Press ¶
func (q *PressableQueue) Press(e interface{}) interface{}
Press is adding element to queue and return nil fi queue is not full, or drop first element and return dropped element if queue is full.
func (*PressableQueue) Size ¶
func (q *PressableQueue) Size() int
Size return the number of element queue has
type StatListener ¶
type StatListener struct {
// contains filtered or unexported fields
}
StatListener make summation
func NewStatLister ¶
func NewStatLister() *StatListener
func (*StatListener) OnDrop ¶
func (l *StatListener) OnDrop(element interface{})
func (*StatListener) OnIn ¶
func (l *StatListener) OnIn(element interface{})
func (*StatListener) OnOut ¶
func (l *StatListener) OnOut(element interface{})