fix: protocol name

This commit is contained in:
Richard Ramos 2022-02-23 11:06:47 -04:00
parent 58f739765e
commit 8d155fb51e
No known key found for this signature in database
GPG Key ID: BD36D48BC9FFC88C
7 changed files with 17 additions and 17 deletions

View File

@ -214,7 +214,7 @@ func Execute(options Options) {
failOnErr(err, "Wakunode") failOnErr(err, "Wakunode")
addPeers(wakuNode, options.Rendezvous.Nodes.Value(), rendezvous.RendezvousID_v001) addPeers(wakuNode, options.Rendezvous.Nodes.Value(), rendezvous.RendezvousID_v001)
addPeers(wakuNode, options.Store.Nodes.Value(), store.StoreID_v20beta3) addPeers(wakuNode, options.Store.Nodes.Value(), store.StoreID_v20beta4)
addPeers(wakuNode, options.LightPush.Nodes.Value(), lightpush.LightPushID_v20beta1) addPeers(wakuNode, options.LightPush.Nodes.Value(), lightpush.LightPushID_v20beta1)
addPeers(wakuNode, options.Filter.Nodes.Value(), filter.FilterID_v20beta1) addPeers(wakuNode, options.Filter.Nodes.Value(), filter.FilterID_v20beta1)

View File

@ -122,7 +122,7 @@ func (w *WakuNode) Status() (isOnline bool, hasHistory bool) {
if !hasLightPush && protocol == string(lightpush.LightPushID_v20beta1) { if !hasLightPush && protocol == string(lightpush.LightPushID_v20beta1) {
hasLightPush = true hasLightPush = true
} }
if !hasStore && protocol == string(store.StoreID_v20beta3) { if !hasStore && protocol == string(store.StoreID_v20beta4) {
hasStore = true hasStore = true
} }
if !hasFilter && protocol == string(filter.FilterID_v20beta1) { if !hasFilter && protocol == string(filter.FilterID_v20beta1) {

View File

@ -486,7 +486,7 @@ func (w *WakuNode) startStore() {
case <-w.quit: case <-w.quit:
return return
case <-ticker.C: case <-ticker.C:
_, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta3), w.log) _, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta4), w.log)
if err == nil { if err == nil {
break peerVerif break peerVerif
} }

View File

@ -61,7 +61,7 @@ func TestResume(t *testing.T) {
defer s2.Stop() defer s2.Stop()
host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL) host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL)
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta3)) err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
require.NoError(t, err) require.NoError(t, err)
msgCount, err := s2.Resume(ctx, "test", []peer.ID{host1.ID()}) msgCount, err := s2.Resume(ctx, "test", []peer.ID{host1.ID()})
@ -104,7 +104,7 @@ func TestResumeWithListOfPeers(t *testing.T) {
defer s2.Stop() defer s2.Stop()
host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL) host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL)
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta3)) err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
require.NoError(t, err) require.NoError(t, err)
msgCount, err := s2.Resume(ctx, "test", []peer.ID{invalidHost.ID(), host1.ID()}) msgCount, err := s2.Resume(ctx, "test", []peer.ID{invalidHost.ID(), host1.ID()})
@ -137,7 +137,7 @@ func TestResumeWithoutSpecifyingPeer(t *testing.T) {
defer s2.Stop() defer s2.Stop()
host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL) host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL)
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta3)) err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
require.NoError(t, err) require.NoError(t, err)
msgCount, err := s2.Resume(ctx, "test", []peer.ID{}) msgCount, err := s2.Resume(ctx, "test", []peer.ID{})

View File

@ -26,8 +26,8 @@ import (
"github.com/status-im/go-waku/waku/v2/utils" "github.com/status-im/go-waku/waku/v2/utils"
) )
// StoreID_v20beta3 is the current Waku Store protocol identifier // StoreID_v20beta4 is the current Waku Store protocol identifier
const StoreID_v20beta3 = libp2pProtocol.ID("/vac/waku/store/2.0.0-beta4") const StoreID_v20beta4 = libp2pProtocol.ID("/vac/waku/store/2.0.0-beta4")
// MaxPageSize is the maximum number of waku messages to return per page // MaxPageSize is the maximum number of waku messages to return per page
const MaxPageSize = 100 const MaxPageSize = 100
@ -266,7 +266,7 @@ func (store *WakuStore) Start(ctx context.Context) {
store.ctx = ctx store.ctx = ctx
store.MsgC = make(chan *protocol.Envelope, 1024) store.MsgC = make(chan *protocol.Envelope, 1024)
store.h.SetStreamHandlerMatch(StoreID_v20beta3, protocol.PrefixTextMatch(string(StoreID_v20beta3)), store.onRequest) store.h.SetStreamHandlerMatch(StoreID_v20beta4, protocol.PrefixTextMatch(string(StoreID_v20beta4)), store.onRequest)
store.wg.Add(1) store.wg.Add(1)
go store.storeIncomingMessages(ctx) go store.storeIncomingMessages(ctx)
@ -446,7 +446,7 @@ func WithPeer(p peer.ID) HistoryRequestOption {
// to request the message history // to request the message history
func WithAutomaticPeerSelection() HistoryRequestOption { func WithAutomaticPeerSelection() HistoryRequestOption {
return func(params *HistoryRequestParameters) { return func(params *HistoryRequestParameters) {
p, err := utils.SelectPeer(params.s.h, string(StoreID_v20beta3), params.s.log) p, err := utils.SelectPeer(params.s.h, string(StoreID_v20beta4), params.s.log)
if err == nil { if err == nil {
params.selectedPeer = *p params.selectedPeer = *p
} else { } else {
@ -457,7 +457,7 @@ func WithAutomaticPeerSelection() HistoryRequestOption {
func WithFastestPeerSelection(ctx context.Context) HistoryRequestOption { func WithFastestPeerSelection(ctx context.Context) HistoryRequestOption {
return func(params *HistoryRequestParameters) { return func(params *HistoryRequestParameters) {
p, err := utils.SelectPeerWithLowestRTT(ctx, params.s.h, string(StoreID_v20beta3), params.s.log) p, err := utils.SelectPeerWithLowestRTT(ctx, params.s.h, string(StoreID_v20beta4), params.s.log)
if err == nil { if err == nil {
params.selectedPeer = *p params.selectedPeer = *p
} else { } else {
@ -504,7 +504,7 @@ func DefaultOptions() []HistoryRequestOption {
func (store *WakuStore) queryFrom(ctx context.Context, q *pb.HistoryQuery, selectedPeer peer.ID, requestId []byte) (*pb.HistoryResponse, error) { func (store *WakuStore) queryFrom(ctx context.Context, q *pb.HistoryQuery, selectedPeer peer.ID, requestId []byte) (*pb.HistoryResponse, error) {
store.log.Info(fmt.Sprintf("Querying message history with peer %s", selectedPeer)) store.log.Info(fmt.Sprintf("Querying message history with peer %s", selectedPeer))
connOpt, err := store.h.NewStream(ctx, selectedPeer, StoreID_v20beta3) connOpt, err := store.h.NewStream(ctx, selectedPeer, StoreID_v20beta4)
if err != nil { if err != nil {
store.log.Error("Failed to connect to remote peer", err) store.log.Error("Failed to connect to remote peer", err)
return nil, err return nil, err
@ -722,7 +722,7 @@ func (store *WakuStore) Resume(ctx context.Context, pubsubTopic string, peerList
} }
if len(peerList) == 0 { if len(peerList) == 0 {
p, err := utils.SelectPeer(store.h, string(StoreID_v20beta3), store.log) p, err := utils.SelectPeer(store.h, string(StoreID_v20beta4), store.log)
if err != nil { if err != nil {
store.log.Info("Error selecting peer: ", err) store.log.Info("Error selecting peer: ", err)
return -1, ErrNoPeersAvailable return -1, ErrNoPeersAvailable
@ -760,7 +760,7 @@ func (store *WakuStore) Stop() {
} }
if store.h != nil { if store.h != nil {
store.h.RemoveStreamHandler(StoreID_v20beta3) store.h.RemoveStreamHandler(StoreID_v20beta4)
} }
store.wg.Wait() store.wg.Wait()

View File

@ -44,7 +44,7 @@ func TestWakuStoreProtocolQuery(t *testing.T) {
defer s2.Stop() defer s2.Stop()
host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL) host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL)
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta3)) err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
require.NoError(t, err) require.NoError(t, err)
q := Query{ q := Query{
@ -89,7 +89,7 @@ func TestWakuStoreProtocolNext(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL) host2.Peerstore().AddAddr(host1.ID(), tests.GetHostAddress(host1), peerstore.PermanentAddrTTL)
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta3)) err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
require.NoError(t, err) require.NoError(t, err)
s2 := NewWakuStore(host2, nil, nil, 0, 0, tests.Logger()) s2 := NewWakuStore(host2, nil, nil, 0, 0, tests.Logger())

View File

@ -59,7 +59,7 @@ func (a *AdminService) PostV1Peers(req *http.Request, args *PeersArgs, reply *Su
} }
func isWakuProtocol(protocol string) bool { func isWakuProtocol(protocol string) bool {
return protocol == string(filter.FilterID_v20beta1) || protocol == string(relay.WakuRelayID_v200) || protocol == string(lightpush.LightPushID_v20beta1) || protocol == string(store.StoreID_v20beta3) return protocol == string(filter.FilterID_v20beta1) || protocol == string(relay.WakuRelayID_v200) || protocol == string(lightpush.LightPushID_v20beta1) || protocol == string(store.StoreID_v20beta4)
} }
func (a *AdminService) GetV1Peers(req *http.Request, args *GetPeersArgs, reply *PeersReply) error { func (a *AdminService) GetV1Peers(req *http.Request, args *GetPeersArgs, reply *PeersReply) error {