mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
210edfc940
* proto: illegal wireType 7 :( * set addr to todo for now so somethign gets sent * push latest progress * Add feedback from @raulk. Stream never connects * working handshake handler * add exclusions for relay/bootstrap node * fix tests, still need to add new ones * remove race, fails coverage * Add test for negotiation * gazelle * regen pb * Update shared/p2p/handshake_handler.go Co-Authored-By: prestonvanloon <preston@prysmaticlabs.com>
24 lines
711 B
Go
24 lines
711 B
Go
package p2p
|
|
|
|
import (
|
|
ggio "github.com/gogo/protobuf/io"
|
|
host "github.com/libp2p/go-libp2p-host"
|
|
inet "github.com/libp2p/go-libp2p-net"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
)
|
|
|
|
// setHandshakeHandler to respond to requests for p2p handshake messages.
|
|
func setHandshakeHandler(host host.Host, contractAddress string) {
|
|
host.SetStreamHandler(handshakeProtocol, func(stream inet.Stream) {
|
|
defer stream.Close()
|
|
log.Debug("Handling handshake stream")
|
|
w := ggio.NewDelimitedWriter(stream)
|
|
defer w.Close()
|
|
|
|
hs := &pb.Handshake{DepositContractAddress: contractAddress}
|
|
if err := w.WriteMsg(hs); err != nil {
|
|
log.WithError(err).Error("Failed to write handshake response")
|
|
}
|
|
})
|
|
}
|