fix: setting peerId for store query (#1278)

This commit is contained in:
gabrielmer 2025-03-20 15:47:51 +02:00 committed by GitHub
parent e68fcdb554
commit fdf03de179
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@ import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
libp2pPeerstore "github.com/libp2p/go-libp2p/core/peerstore"
libp2pProtocol "github.com/libp2p/go-libp2p/core/protocol"
"github.com/libp2p/go-msgio/pbio"
"github.com/waku-org/go-waku/logging"
@ -204,10 +205,14 @@ func (s *WakuStore) RequestRaw(ctx context.Context, peerInfo peer.AddrInfo, stor
var params Parameters
params.peerAddr = peerInfo.Addrs
if len(params.peerAddr) == 0 {
params.selectedPeer = peerInfo.ID
if len(params.peerAddr) == 0 || params.selectedPeer == "" {
return nil, ErrMustSelectPeer
}
//Add Peer to peerstore.
s.h.Peerstore().AddAddrs(peerInfo.ID, peerInfo.Addrs, libp2pPeerstore.AddressTTL)
response, err := s.queryFrom(ctx, storeRequest, &params)
if err != nil {
return nil, err