From 80e2ef4eb5853533015c2c7337e57dc33dd449b4 Mon Sep 17 00:00:00 2001 From: Ben Bierens <39762930+benbierens@users.noreply.github.com> Date: Sun, 12 Nov 2023 09:58:40 +0100 Subject: [PATCH] Debug/info shows announce addresses (#610) * Shows announce addresses in debug/info endpoint. * Shows announce addresses in debug/info endpoint. --- codex/discovery.nim | 8 ++++---- codex/rest/api.nim | 1 + codex/rest/json.nim | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/codex/discovery.nim b/codex/discovery.nim index dda8607e..45430af5 100644 --- a/codex/discovery.nim +++ b/codex/discovery.nim @@ -36,7 +36,7 @@ type protocol*: discv5.Protocol # dht protocol key: PrivateKey # private key peerId: PeerId # the peer id of the local node - announceAddrs: seq[MultiAddress] # addresses announced as part of the provider records + announceAddrs*: seq[MultiAddress] # addresses announced as part of the provider records providerRecord*: ?SignedPeerRecord # record to advertice node connection information, this carry any # address that the node can be connected on dhtRecord*: ?SignedPeerRecord # record to advertice DHT connection information @@ -74,7 +74,7 @@ method find*( cid: Cid ): Future[seq[SignedPeerRecord]] {.async, base.} = ## Find block providers - ## + ## trace "Finding providers for block", cid without providers =? @@ -187,8 +187,8 @@ proc new*( bootstrapNodes: openArray[SignedPeerRecord] = [], store: Datastore = SQLiteDatastore.new(Memory).expect("Should not fail!") ): Discovery = - ## Create a new Discovery node instance for the given key and datastore - ## + ## Create a new Discovery node instance for the given key and datastore + ## var self = Discovery( diff --git a/codex/rest/api.nim b/codex/rest/api.nim index 5b47b86d..84a7aa40 100644 --- a/codex/rest/api.nim +++ b/codex/rest/api.nim @@ -298,6 +298,7 @@ proc initDebugApi(node: CodexNodeRef, conf: CodexConf, router: var RestRouter) = node.discovery.dhtRecord.get.toURI else: "", + "announceAddresses": node.discovery.announceAddrs, "table": table, "codex": { "version": $codexVersion, diff --git a/codex/rest/json.nim b/codex/rest/json.nim index 49ac4f58..018ab2e1 100644 --- a/codex/rest/json.nim +++ b/codex/rest/json.nim @@ -108,3 +108,6 @@ func `%`*(obj: dn.Address): JsonNode = func `%`*(obj: AddressInfo): JsonNode = % $obj.address + +func `%`*(obj: MultiAddress): JsonNode = + % $obj