p2p

package
v1.14.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: LGPL-3.0 Imports: 3 Imported by: 21

Documentation

Overview

  • Copyright (C) 2018 The ontology Authors
  • This file is part of The ontology library. *
  • The ontology is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Lesser General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • The ontology is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Lesser General Public License for more details. *
  • You should have received a copy of the GNU Lesser General Public License
  • along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Package p2p provides an network interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressFilter added in v1.11.0

type AddressFilter interface {
	// addr format : ip:port
	Contains(addr string) bool
}

func AllAddrFilter added in v1.11.0

func AllAddrFilter() AddressFilter

func CombineAddrFilter added in v1.11.0

func CombineAddrFilter(filter1, filter2 AddressFilter) AddressFilter

func NoneAddrFilter added in v1.11.0

func NoneAddrFilter() AddressFilter

type Context added in v1.10.0

type Context struct {
	MsgSize uint32
	// contains filtered or unexported fields
}

func NewContext added in v1.10.0

func NewContext(sender *peer.Peer, net P2P, msgSize uint32) *Context

func (*Context) Network added in v1.10.0

func (self *Context) Network() P2P

func (*Context) Sender added in v1.10.0

func (self *Context) Sender() *peer.Peer

type HostAddrDetected added in v1.11.0

type HostAddrDetected struct {
	ListenAddr string
	// contains filtered or unexported fields
}

type NetworkStart added in v1.10.0

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

type NetworkStop added in v1.10.0

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

type P2P

type P2P interface {
	Connect(addr string)
	GetHostInfo() *peer.PeerInfo
	GetID() common.PeerId
	GetNeighbors() []*peer.Peer
	GetNeighborAddrs() []common.PeerAddr
	GetConnectionCnt() uint32
	GetMaxPeerBlockHeight() uint64
	GetPeer(id common.PeerId) *peer.Peer
	SetHeight(uint64)
	Send(p *peer.Peer, msg types.Message) error
	SendTo(p common.PeerId, msg types.Message)
	GetOutConnRecordLen() uint
	Broadcast(msg types.Message)
	IsOwnAddress(addr string) bool
}

P2P represent the net interface of p2p package

type PeerConnected added in v1.10.0

type PeerConnected struct {
	Info *peer.PeerInfo
	// contains filtered or unexported fields
}

type PeerDisConnected added in v1.10.0

type PeerDisConnected struct {
	Info *peer.PeerInfo
	// contains filtered or unexported fields
}

type Protocol added in v1.10.0

type Protocol interface {
	HandlePeerMessage(ctx *Context, msg types.Message)
	HandleSystemMessage(net P2P, msg SystemMessage)
}

type SystemMessage added in v1.10.0

type SystemMessage interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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