p2p

package
v0.0.0-...-54ab005 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: LGPL-3.0 Imports: 3 Imported by: 0

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

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

func AllAddrFilter

func AllAddrFilter() AddressFilter

func CombineAddrFilter

func CombineAddrFilter(filter1, filter2 AddressFilter) AddressFilter

func NoneAddrFilter

func NoneAddrFilter() AddressFilter

type Context

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

func NewContext

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

func (*Context) Network

func (self *Context) Network() P2P

func (*Context) Sender

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

type HostAddrDetected

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

type NetworkStart

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

type NetworkStop

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

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

type PeerDisConnected

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

type Protocol

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

type SystemMessage

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