eth: check snap satelliteness, delegate drop to eth (#22235)

* eth: check snap satelliteness, delegate drop to eth

* eth: better handle eth/snap satellite relation, merge reg/unreg paths
This commit is contained in:
Péter Szilágyi
2021-02-02 10:44:36 +02:00
committed by GitHub
parent 3c728fb129
commit e3430ac7df
13 changed files with 217 additions and 252 deletions

View File

@ -103,12 +103,12 @@ type TxPool interface {
// MakeProtocols constructs the P2P protocol definitions for `eth`.
func MakeProtocols(backend Backend, network uint64, dnsdisc enode.Iterator) []p2p.Protocol {
protocols := make([]p2p.Protocol, len(protocolVersions))
for i, version := range protocolVersions {
protocols := make([]p2p.Protocol, len(ProtocolVersions))
for i, version := range ProtocolVersions {
version := version // Closure
protocols[i] = p2p.Protocol{
Name: protocolName,
Name: ProtocolName,
Version: version,
Length: protocolLengths[version],
Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {

View File

@ -34,13 +34,13 @@ const (
ETH65 = 65
)
// protocolName is the official short name of the `eth` protocol used during
// ProtocolName is the official short name of the `eth` protocol used during
// devp2p capability negotiation.
const protocolName = "eth"
const ProtocolName = "eth"
// protocolVersions are the supported versions of the `eth` protocol (first
// ProtocolVersions are the supported versions of the `eth` protocol (first
// is primary).
var protocolVersions = []uint{ETH65, ETH64}
var ProtocolVersions = []uint{ETH65, ETH64}
// protocolLengths are the number of implemented message corresponding to
// different protocol versions.

View File

@ -77,12 +77,12 @@ type Backend interface {
// MakeProtocols constructs the P2P protocol definitions for `snap`.
func MakeProtocols(backend Backend, dnsdisc enode.Iterator) []p2p.Protocol {
protocols := make([]p2p.Protocol, len(protocolVersions))
for i, version := range protocolVersions {
protocols := make([]p2p.Protocol, len(ProtocolVersions))
for i, version := range ProtocolVersions {
version := version // Closure
protocols[i] = p2p.Protocol{
Name: protocolName,
Name: ProtocolName,
Version: version,
Length: protocolLengths[version],
Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {

View File

@ -30,13 +30,13 @@ const (
snap1 = 1
)
// protocolName is the official short name of the `snap` protocol used during
// ProtocolName is the official short name of the `snap` protocol used during
// devp2p capability negotiation.
const protocolName = "snap"
const ProtocolName = "snap"
// protocolVersions are the supported versions of the `snap` protocol (first
// ProtocolVersions are the supported versions of the `snap` protocol (first
// is primary).
var protocolVersions = []uint{snap1}
var ProtocolVersions = []uint{snap1}
// protocolLengths are the number of implemented message corresponding to
// different protocol versions.