2018-11-01 11:02:01 +00:00
|
|
|
// Package p2p handles peer-to-peer networking for Ethereum Serenity clients.
|
2018-08-29 16:32:54 +00:00
|
|
|
//
|
|
|
|
// There are three types of p2p communications.
|
|
|
|
//
|
|
|
|
// - Direct: two peer communication
|
|
|
|
// - Floodsub: peer broadcasting to all peers
|
|
|
|
// - Gossipsub: peer broadcasting to localized peers
|
|
|
|
//
|
|
|
|
// This communication is abstracted through the Feed, Broadcast, and Send.
|
|
|
|
//
|
2018-09-20 04:14:31 +00:00
|
|
|
// Pub/sub topic has a specific message type that is used for that topic.
|
2018-08-29 16:32:54 +00:00
|
|
|
//
|
|
|
|
// Read more about gossipsub at https://github.com/vyzo/gerbil-simsub
|
|
|
|
package p2p
|
|
|
|
|
2019-03-08 04:54:41 +00:00
|
|
|
import peer "github.com/libp2p/go-libp2p-peer"
|
2019-03-08 02:37:15 +00:00
|
|
|
|
|
|
|
// AnyPeer represents a Peer ID alias for sending to any available peer(s).
|
|
|
|
const AnyPeer = peer.ID("AnyPeer")
|
|
|
|
|
2018-08-29 16:32:54 +00:00
|
|
|
// Use this file for interfaces only!
|
|
|
|
|
|
|
|
// Adapter is used to create middleware.
|
|
|
|
//
|
|
|
|
// See http://godoc.org/github.com/prysmaticlabs/prysm/shared/p2p#Server.RegisterTopic
|
|
|
|
type Adapter func(Handler) Handler
|
|
|
|
|
|
|
|
// Handler is a callback used in the adapter/middleware stack chain.
|
|
|
|
//
|
|
|
|
// See http://godoc.org/github.com/prysmaticlabs/prysm/shared/p2p#Server.RegisterTopic
|
2018-09-20 11:46:35 +00:00
|
|
|
type Handler func(Message)
|