Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PeerExchange rpc decode in order not to take response's status_code mandatory - for support old protocol implementation #3059

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion waku/waku_peer_exchange/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ proc populateEnrCache(wpx: WakuPeerExchange) =

proc updatePxEnrCache(wpx: WakuPeerExchange) {.async.} =
# try more aggressively to fill the cache at startup
while wpx.enrCache.len < MaxPeersCacheSize:
var attempts = 10
while wpx.enrCache.len < MaxPeersCacheSize and attempts > 0:
attempts -= 1
Ivansete-status marked this conversation as resolved.
Show resolved Hide resolved
wpx.populateEnrCache()
await sleepAsync(5.seconds)

Expand Down
6 changes: 5 additions & 1 deletion waku/waku_peer_exchange/rpc_codec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ proc decode*(T: type PeerExchangeResponse, buffer: seq[byte]): ProtobufResult[T]
if ?pb.getField(10, status_code):
rpc.status_code = PeerExchangeResponseStatusCode.parse(status_code)
else:
return err(ProtobufError.missingRequiredField("status_code"))
# older peers may not support status_code field yet
if rpc.peerInfos.len() > 0:
rpc.status_code = PeerExchangeResponseStatusCode.SUCCESS
else:
rpc.status_code = PeerExchangeResponseStatusCode.SERVICE_UNAVAILABLE

var status_desc: string
if ?pb.getField(11, status_desc):
Expand Down
Loading