mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-30 00:23:46 +00:00
fix: protal protocol type error
This commit is contained in:
parent
17d1601eec
commit
8651f5b4af
6 changed files with 26 additions and 22 deletions
|
|
@ -1,13 +1,13 @@
|
|||
FROM golang:1.20.13 as builder
|
||||
FROM --platform=linux/amd64 golang:1.20.13 as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go env -w GOPROXY=https://goproxy.cn,direct
|
||||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build ./cmd/hive/main.go
|
||||
|
||||
|
||||
FROM ubuntu:22.04
|
||||
FROM --platform=linux/amd64 ubuntu:22.04
|
||||
|
||||
COPY --from=builder /app/main /usr/local/bin/app
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover/portalwire"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/portalnetwork/storage/sqlite"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
|
|
@ -61,7 +62,7 @@ func main() {
|
|||
|
||||
contentQueue := make(chan *discover.ContentElement, 50)
|
||||
|
||||
protocol, err := discover.NewPortalProtocol(config, "history", privateKey, contentStorage, contentQueue)
|
||||
protocol, err := discover.NewPortalProtocol(config, string(portalwire.HistoryNetwork), privateKey, contentStorage, contentQueue)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ func (p *PortalProtocol) Start() error {
|
|||
}
|
||||
|
||||
p.DiscV5.RegisterTalkHandler(p.protocolId, p.handleTalkRequest)
|
||||
p.DiscV5.RegisterTalkHandler(portalwire.UTPNetwork, p.handleUtpTalkRequest)
|
||||
p.DiscV5.RegisterTalkHandler(string(portalwire.UTPNetwork), p.handleUtpTalkRequest)
|
||||
|
||||
go p.table.loop()
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ func (p *PortalProtocol) setupUDPListening() (*net.UDPConn, error) {
|
|||
}
|
||||
|
||||
p.log.Trace("send to target data", "ip", target.IP().String(), "port", target.UDP(), "bufLength", len(buf))
|
||||
_, err := p.DiscV5.TalkRequest(target, portalwire.UTPNetwork, buf)
|
||||
_, err := p.DiscV5.TalkRequest(target, string(portalwire.UTPNetwork), buf)
|
||||
return len(buf), err
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func setupLocalPortalNode(addr string, bootNodes []*enode.Node) (*PortalProtocol
|
|||
}
|
||||
|
||||
contentQueue := make(chan *ContentElement, 50)
|
||||
portalProtocol, err := NewPortalProtocol(conf, portalwire.HistoryNetwork, newkey(), &MockStorage{db: make(map[string][]byte)}, contentQueue)
|
||||
portalProtocol, err := NewPortalProtocol(conf, string(portalwire.HistoryNetwork), newkey(), &MockStorage{db: make(map[string][]byte)}, contentQueue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -75,8 +75,11 @@ func TestPortalWireProtocolUdp(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
node1Addr, _ := utp.ResolveUTPAddr("utp", "127.0.0.1:8777")
|
||||
node2Addr, _ := utp.ResolveUTPAddr("utp", "127.0.0.1:8778")
|
||||
udpAddrStr1 := fmt.Sprintf("%s:%d", node1.localNode.Node().IP(), node1.localNode.Node().UDP())
|
||||
udpAddrStr2 := fmt.Sprintf("%s:%d", node2.localNode.Node().IP(), node2.localNode.Node().UDP())
|
||||
|
||||
node1Addr, _ := utp.ResolveUTPAddr("utp", udpAddrStr1)
|
||||
node2Addr, _ := utp.ResolveUTPAddr("utp", udpAddrStr2)
|
||||
|
||||
cid := uint32(12)
|
||||
cliSendMsgWithCid := "there are connection id : 12!"
|
||||
|
|
|
|||
|
|
@ -2,18 +2,6 @@ package portalwire
|
|||
|
||||
//go:generate sszgen --path p2p/discover/portalwire/messages.go --exclude-objs BlockHeaderProof,PortalReceipts
|
||||
|
||||
// Protocol IDs for the portal protocol.
|
||||
const (
|
||||
StateNetwork = "0x500a"
|
||||
HistoryNetwork = "0x500b"
|
||||
TxGossipNetwork = "0x500c"
|
||||
HeaderGossipNetwork = "0x500d"
|
||||
CanonicalIndicesNetwork = "0x500e"
|
||||
BeaconLightClientNetwork = "0x501a"
|
||||
UTPNetwork = "0x757470"
|
||||
Rendezvous = "0x72656e"
|
||||
)
|
||||
|
||||
// Message codes for the portal protocol.
|
||||
const (
|
||||
PING byte = 0x00
|
||||
|
|
@ -50,6 +38,18 @@ const (
|
|||
PerContentKeyOverhead = 4
|
||||
)
|
||||
|
||||
// Protocol IDs for the portal protocol.
|
||||
var (
|
||||
StateNetwork = []byte{0x50, 0x0a}
|
||||
HistoryNetwork = []byte{0x50, 0x0b}
|
||||
TxGossipNetwork = []byte{0x50, 0x0c}
|
||||
HeaderGossipNetwork = []byte{0x50, 0x0d}
|
||||
CanonicalIndicesNetwork = []byte{0x50, 0x0e}
|
||||
BeaconLightClientNetwork = []byte{0x50, 0x1a}
|
||||
UTPNetwork = []byte{0x75, 0x74, 0x70}
|
||||
Rendezvous = []byte{0x72, 0x65, 0x6e}
|
||||
)
|
||||
|
||||
type ContentKV struct {
|
||||
ContentKey []byte
|
||||
Content []byte
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ func genHistoryNetwork(addr string, bootNodes []*enode.Node) (*HistoryNetwork, e
|
|||
panic("couldn't generate key: " + err.Error())
|
||||
}
|
||||
|
||||
portalProtocol, err := discover.NewPortalProtocol(conf, portalwire.HistoryNetwork, key, &MockStorage{db: make(map[string][]byte)}, contentQueue)
|
||||
portalProtocol, err := discover.NewPortalProtocol(conf, string(portalwire.HistoryNetwork), key, &MockStorage{db: make(map[string][]byte)}, contentQueue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue