[rpc] Add getnodeaddresses RPC command #13152

pull chris-belcher wants to merge 1 commits into bitcoin:master from chris-belcher:2018-04-rpc-getaddress changing 4 files +97 −0
  1. chris-belcher commented at 12:43 pm on May 2, 2018: contributor

    Implements issue #9463

    New getnodeaddresses call gives access via RPC to the peers known by the node. It may be useful for bitcoin wallets to broadcast their transactions over tor for improved privacy without using the centralized DNS seeds. getnodeaddresses is very similar to the getaddr p2p method.

    Please advise me on the best approach for writing an automated test. By my reading the getaddr p2p method also isn’t really tested.

  2. fanquake added the label RPC/REST/ZMQ on May 2, 2018
  3. laanwj commented at 1:04 pm on May 2, 2018: member
    Concept ACK, this would indeed be useful.
  4. in src/rpc/net.cpp:665 in a5e0fc8eaf outdated
    660+    // returns a shuffled list of CAddress
    661+    std::vector<CAddress> vAddr = g_connman->GetAddresses();
    662+    UniValue ret(UniValue::VARR);
    663+
    664+    int address_return_count = std::min(count, (int)vAddr.size());
    665+    for(int i = 0; i < address_return_count; ++i) {
    


    promag commented at 1:08 pm on May 2, 2018:
    Nit, space after for.
  5. in src/rpc/net.cpp:634 in a5e0fc8eaf outdated
    629+    if (request.fHelp || request.params.size() > 1) {
    630+        throw std::runtime_error(
    631+            "getaddress ( count )\n"
    632+            "\nReturn known addresses which can potentially be used to find new nodes in the network\n"
    633+            "\nArguments:\n"
    634+            "1. \"count\"    (numeric, optional) How many addresses to return, if available (default = 1)\n"
    


    promag commented at 1:10 pm on May 2, 2018:
    Why not return all?

    chris-belcher commented at 3:35 pm on May 2, 2018:
    Returning all would typically result in a massive json array with thousands of entries, about 2500 or so depending. Normally applications only need to connect to a few nodes, they don’t need anywhere near that many.
  6. promag commented at 1:12 pm on May 2, 2018: member
    Why not extend getpeerinfo?
  7. promag commented at 1:14 pm on May 2, 2018: member

    Please advise me on the best approach for writing an automated test

    At least it can test arguments (valid and invalid) and result format and fields (their presence and types).

  8. laanwj commented at 1:23 pm on May 2, 2018: member

    I think this call should be called differently. getaddress is too easy to confuse with a bitcoin address (e.g. getnewaddress). Maybe getnodeaddresses?

    Why not extend getpeerinfo?

    You misunderstand what this does. It doesn’t return currently conneced nodes, but potentially connectable addresses.

  9. chris-belcher force-pushed on May 2, 2018
  10. chris-belcher commented at 2:16 pm on May 2, 2018: contributor

    Renamed to getnodeaddresses and fixed nits.

    Looks like something went wrong with the rebase and now other people’s commits are involved too. Does anyone know how I can fix this. (edit: fixed)

    At least it can test arguments (valid and invalid) and result format and fields (their presence and types).

    I think in the test suite the node won’t know about any other addresses, so this RPC will return an empty json object, so it can’t be tested. What would be the best way around this? Maybe to populate the vAddr somehow.

  11. chris-belcher force-pushed on May 2, 2018
  12. chris-belcher force-pushed on May 2, 2018
  13. chris-belcher commented at 3:32 pm on May 2, 2018: contributor
    Fixed git weirdness (thanks to viasil).
  14. promag commented at 4:02 pm on May 2, 2018: member
    Please rename PR.
  15. chris-belcher renamed this:
    [WIP] [rpc] Add getaddress RPC command
    [WIP] [rpc] Add getnodeaddresses RPC command
    on May 2, 2018
  16. MasterGrad17 commented at 8:32 pm on May 2, 2018: none
    Does getnodeaddresses command return a list of reachable nodes in the network known by a node? like the result of getaddr message? is getaddress/getnodeaddresses RPC command currently available in v0.16.0rc4?
  17. chris-belcher commented at 8:37 pm on May 2, 2018: contributor
    @MasterGrad17 Yes the result is very similar as from the p2p getaddr method. The addresses come from gossiping between nodes, so the IP address may be reachable but that isn’t guaranteed.
  18. sipa commented at 9:29 pm on May 2, 2018: member
    @MasterGrad17 You’re commenting on the request to get it merged into Bitcoin Core, so obviously no.
  19. in src/rpc/net.cpp:641 in c83ccf76b0 outdated
    636+            "[\n"
    637+            "  {\n"
    638+            "    \"time\": ttt,                        (numeric) Address timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
    639+            "    \"services\": n,                      (numeric) The services offered\n"
    640+            "    \"servicesHex\": \"xxxxxxxxxxxxxxxx\",  (string) The hex string of services offered\n"
    641+            "    \"addr\": \"host\",                     (string) The IP address of the peer\n"
    


    jonasschnelli commented at 6:58 am on May 3, 2018:
    nit: could also be a tor address
  20. in src/rpc/net.cpp:670 in c83ccf76b0 outdated
    665+    for (int i = 0; i < address_return_count; ++i) {
    666+        UniValue obj(UniValue::VOBJ);
    667+        CAddress addr = vAddr[i];
    668+        obj.pushKV("time", (int)addr.nTime);
    669+        obj.pushKV("services", addr.nServices);
    670+        obj.pushKV("servicesHex", strprintf("%016x", addr.nServices));
    


    jonasschnelli commented at 7:01 am on May 3, 2018:
    would be handy to have a string representation here. Like ("NODE_NETWORK | NODE_NETWORK_LIMITED | NODE_BLOOM", etc.). But can be done later.
  21. jonasschnelli changes_requested
  22. jonasschnelli commented at 7:03 am on May 3, 2018: contributor
    Almost utACK c83ccf76b0df2aceedddc23c8e081e877e5a878d. Please rename command. Maybe listpeeraddresses()
  23. sipa commented at 7:09 am on May 3, 2018: member
    @jonasschnelli listpeeraddresses sounds like it’s somehow exhaustive, or at least a complete specific subset of addresses. It’s just giving a bunch of random ones; getpeeraddresses sounds clearer to me. Am i missing something?
  24. jonasschnelli commented at 7:16 am on May 3, 2018: contributor

    listpeeraddresses sounds like it’s somehow exhaustive, or at least a complete specific subset of addresses. It’s just giving a bunch of random ones; getpeeraddresses sounds clearer to me. Am I missing something?

    Good point.

  25. chris-belcher commented at 9:20 am on May 3, 2018: contributor
    peer implies it returns addresses of peers you’re actually connected to. Like how getpeerinfo gives information only about connected peers. How about getpossiblepeeraddresses? It’s a bit of a mouthful admittedly. Other options could be getgossipedpeeraddresses or getpotentialpeeraddresses.
  26. laanwj commented at 9:50 am on May 3, 2018: member
    Yes, I intentionally avoided ‘peer’ in my suggested name for that reason, as it’s easy to confuse and a lot of people confused it already. Also let’s stop asking the guy to rename his RPC call :) I think getnodeaddresses is fine, just make sure that the documentation explains the functionality.
  27. chris-belcher force-pushed on May 3, 2018
  28. chris-belcher force-pushed on May 3, 2018
  29. chris-belcher commented at 1:03 pm on May 3, 2018: contributor
    Fixed nit
  30. in src/rpc/net.cpp:634 in 9e6cac24db outdated
    629+    if (request.fHelp || request.params.size() > 1) {
    630+        throw std::runtime_error(
    631+            "getnodeaddresses ( count )\n"
    632+            "\nReturn known addresses which can potentially be used to find new nodes in the network\n"
    633+            "\nArguments:\n"
    634+            "1. \"count\"    (numeric, optional) How many addresses to return, if available (default = 1)\n"
    


    jnewbery commented at 5:50 pm on May 3, 2018:

    Should document that the maximum number of nodes to return is:

    • 2500 (due to ADDRMAN_GETADDR_MAX in CAddrMan::GetAddr_()); or
    • 23% of all known nodes. (whichever is smaller)
  31. in src/rpc/net.cpp:638 in 9e6cac24db outdated
    633+            "\nArguments:\n"
    634+            "1. \"count\"    (numeric, optional) How many addresses to return, if available (default = 1)\n"
    635+            "\nResult:\n"
    636+            "[\n"
    637+            "  {\n"
    638+            "    \"time\": ttt,                        (numeric) Address timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
    


    jnewbery commented at 5:54 pm on May 3, 2018:
    What does ‘address timestamp’ mean here?
  32. in src/rpc/net.cpp:640 in 9e6cac24db outdated
    635+            "\nResult:\n"
    636+            "[\n"
    637+            "  {\n"
    638+            "    \"time\": ttt,                        (numeric) Address timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
    639+            "    \"services\": n,                      (numeric) The services offered\n"
    640+            "    \"servicesHex\": \"xxxxxxxxxxxxxxxx\",  (string) The hex string of services offered\n"
    


    jnewbery commented at 5:57 pm on May 3, 2018:
    return fields should be named in camel_case
  33. in src/rpc/net.cpp:641 in 9e6cac24db outdated
    636+            "[\n"
    637+            "  {\n"
    638+            "    \"time\": ttt,                        (numeric) Address timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
    639+            "    \"services\": n,                      (numeric) The services offered\n"
    640+            "    \"servicesHex\": \"xxxxxxxxxxxxxxxx\",  (string) The hex string of services offered\n"
    641+            "    \"addr\": \"host\",                     (string) The address of the peer\n"
    


    jnewbery commented at 5:58 pm on May 3, 2018:
    prefer to name this address. No need to save characters!
  34. in src/rpc/net.cpp:639 in 9e6cac24db outdated
    634+            "1. \"count\"    (numeric, optional) How many addresses to return, if available (default = 1)\n"
    635+            "\nResult:\n"
    636+            "[\n"
    637+            "  {\n"
    638+            "    \"time\": ttt,                        (numeric) Address timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
    639+            "    \"services\": n,                      (numeric) The services offered\n"
    


    jnewbery commented at 6:46 pm on May 3, 2018:
    I don’t think this is useful. Services is a bitfield. Displaying it as an int doesn’t give any useful information to the user. Just display the hex version.

    laanwj commented at 11:43 am on May 7, 2018:
    Depends on what ’the user’ is. Programmatic RPC users will want the int, not have to do an additional step of parsing a hex string (though I don’t care deeply in this case, just be mindful that manual command-line users are not the only clients of the RPC interface).

    jnewbery commented at 12:56 pm on May 7, 2018:

    be mindful that manual command-line users are not the only clients of the RPC interface

    Yes good point. In general though, I think we should avoid RPCs returning the same data in multiple formats.

  35. jnewbery commented at 6:49 pm on May 3, 2018: member

    A few nits inline.

    You should be able to test this in the functional test framework as follows:

    • start a node
    • add a P2PConnection to the node
    • send a msg_addr to the node with some addresses
    • call the new getnodeaddresses RPC
    • assert that the node addresses returned are the same as those sent in the p2p ADDR message.

    Take a look at example_test.py for some pointers on how to write test cases. I think it makes sense to add this new test case to the rpc_net.py script.

    Feel free to reach me on irc (jnewbery) if you need any pointers.

  36. chris-belcher force-pushed on May 10, 2018
  37. chris-belcher force-pushed on May 21, 2018
  38. chris-belcher commented at 4:27 pm on May 21, 2018: contributor
    Fixed nits and created a test in rpc_net.py.
  39. in src/rpc/net.cpp:627 in dd7e1e6f19 outdated
    623@@ -624,6 +624,55 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
    624     return g_connman->GetNetworkActive();
    625 }
    626 
    627+UniValue getnodeaddresses(const JSONRPCRequest& request)
    


    jnewbery commented at 5:01 pm on May 21, 2018:
    nit: should be static
  40. in test/functional/rpc_net.py:20 in dd7e1e6f19 outdated
    16@@ -16,6 +17,8 @@
    17     p2p_port,
    18     wait_until,
    19 )
    20+from test_framework.mininode import P2PInterface, network_thread_start
    


    jnewbery commented at 5:13 pm on May 21, 2018:
    nit: sort imports (in PEP-8 ordering)
  41. in test/functional/rpc_net.py:115 in dd7e1e6f19 outdated
    110+        now = int(time.time())
    111+        msg = msg_addr()
    112+        for a in imported_addrs:
    113+            addr = CAddress()
    114+            addr.time = now
    115+            addr.services = NODE_NETWORK | NODE_WITNESS
    


    jnewbery commented at 5:27 pm on May 21, 2018:
    Should be nServices
  42. in test/functional/rpc_net.py:109 in dd7e1e6f19 outdated
    104+        self.nodes[0].add_p2p_connection(P2PInterface())
    105+        network_thread_start()
    106+        self.nodes[0].p2p.wait_for_verack()
    107+
    108+        # send some addresses to the node via the p2p message addr
    109+        imported_addrs = set(["123.123." + str(i//255) + "." + str(i%255) for i in range(1000)])
    


    jnewbery commented at 5:30 pm on May 21, 2018:

    nit: move this into the range loop below and use string formatters rather than concatenation:

    0        # send some addresses to the node via the p2p message addr
    1        now = int(time.time())
    2        msg = msg_addr()
    3        imported_addrs = []
    4        for i in range(1000):
    5            a = "123.123.{}.{}".format(i // 255, i % 256)
    6            imported_addrs.append(a)
    7            addr = CAddress()
    8            ...
    
  43. in test/functional/rpc_net.py:125 in dd7e1e6f19 outdated
    120+
    121+        # obtain addresses via rpc call and check they are a subset
    122+        NODE_ADDRESSES_REQUEST_COUNT = 10
    123+        node_addresses = self.nodes[0].getnodeaddresses(NODE_ADDRESSES_REQUEST_COUNT)
    124+        assert len(node_addresses) == NODE_ADDRESSES_REQUEST_COUNT
    125+        assert set([addr["address"] for addr in node_addresses]).issubset(imported_addrs)
    


    jnewbery commented at 5:32 pm on May 21, 2018:

    nit: drop the set comparisons, loop over the return items and test all fields, eg:

    0        for a in node_addresses:
    1            assert a["address"] in imported_addrs
    2            assert_equal(a["services"], NODE_NETWORK | NODE_WITNESS)
    3            assert_equal(a["time"], now)
    4            assert_equal(a["port"], 8333)
    
  44. jnewbery commented at 5:33 pm on May 21, 2018: member

    New test is great. Thanks for adding it!

    A few nits inline. Feel free to take or leave them.

  45. in test/functional/rpc_net.py:9 in dd7e1e6f19 outdated
    5@@ -6,6 +6,7 @@
    6 
    7 Tests correspond to code in rpc/net.cpp.
    8 """
    9+import time
    


    jnewbery commented at 5:41 pm on May 21, 2018:
    nit: You’re only using time to set the time field in the ADDR message. As long as the CAddress’s time is greater than 100000000, it’ll be accepted. You can avoid this import by just setting time to 100000000 + i or similar
  46. chris-belcher force-pushed on May 21, 2018
  47. chris-belcher commented at 7:25 pm on May 21, 2018: contributor

    Fixed nits, thanks for reviewing @jnewbery.

    bitcoind modifies the timestamp so it’s complicated to check whether the time was equal. That’s not the point of the RPC or the test anyway so the test only checks whether the “time” field exists.

  48. in test/functional/rpc_net.py:110 in 21f7a19087 outdated
    105+
    106+        # send some addresses to the node via the p2p message addr
    107+        msg = msg_addr()
    108+        imported_addrs = []
    109+        for i in range(1000):
    110+            a = "123.123.{}.{}".format(i // 255, i % 256)
    


    jnewbery commented at 8:53 pm on May 21, 2018:

    Note that you’ll only ever be able to get a maximum of 64 entries into the new addresses buckets by doing this. All of these addresses are in the same /16 address range, which means that addrman will place them into the same new bucket, and start evicting addresses once there are 64 entries (see the comment in addrman.h).

    You may wish to simplify this to just send 256 addresses:

    0        for i in range(256):
    1            a = "123.123.123.{}".format(i)
    
  49. jnewbery commented at 8:58 pm on May 21, 2018: member

    One more comment inline, which answers the question you had on #bitcoin-core-dev IRC earlier.

    bitcoind modifies the timestamp so it’s complicated to check whether the time was equal.

    bitcoind modifies the timestamp if it falls outside these bounds:

    0            if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
    1                addr.nTime = nNow - 5 * 24 * 60 * 60;
    

    but getting a valid time in that range is a bit difficult. if the time is greater than 30 days old, then the address will be marked as IsTerrible and won’t be returned in your RPC call. You could set the node’s mock time and then test that the returned time is that + (5 * 24 * 60 * 60).

  50. jnewbery commented at 9:06 pm on May 21, 2018: member
    @jonasschnelli - can you remove your ‘changes requested’ status?
  51. chris-belcher force-pushed on May 21, 2018
  52. chris-belcher renamed this:
    [WIP] [rpc] Add getnodeaddresses RPC command
    [rpc] Add getnodeaddresses RPC command
    on May 22, 2018
  53. jonasschnelli approved
  54. jonasschnelli commented at 1:59 pm on June 12, 2018: contributor

    utACK f10e38063048294afc6bd45c3a51687cdbdd96a3

    (sorry for the delay)

  55. DrahtBot added the label Needs rebase on Jul 20, 2018
  56. chris-belcher force-pushed on Jul 23, 2018
  57. jnewbery commented at 8:50 pm on July 23, 2018: member
    Needs rebase. The rpc_net.py functional test is failing.
  58. DrahtBot removed the label Needs rebase on Jul 24, 2018
  59. ajtowns commented at 10:44 am on August 16, 2018: member
    The rpc_net.py test looks like it just needs the references to network_thread_start removed, in line with #13517
  60. chris-belcher force-pushed on Aug 16, 2018
  61. chris-belcher commented at 4:15 pm on August 16, 2018: contributor
    Fixed the broken test
  62. ajtowns commented at 9:58 am on August 17, 2018: member
    utACK 316201485933b4fcdf8d4005d823effdfc4b913b
  63. DrahtBot added the label Needs rebase on Aug 27, 2018
  64. in test/functional/rpc_net.py:103 in 3162014859 outdated
     97@@ -96,5 +98,34 @@ def _test_getpeerinfo(self):
     98         assert_equal(peer_info[0][0]['addrbind'], peer_info[1][0]['addr'])
     99         assert_equal(peer_info[1][0]['addrbind'], peer_info[0][0]['addr'])
    100 
    101+    def _test_getnodeaddresses(self):
    102+        self.nodes[0].add_p2p_connection(P2PInterface())
    103+        self.nodes[0].p2p.wait_for_verack()
    


    jnewbery commented at 5:40 pm on August 27, 2018:
    This is no longer required (add_p2p_connection() calls wait_for_verack() now)
  65. jnewbery commented at 5:43 pm on August 27, 2018: member

    Looks great. tACK 316201485933b4fcdf8d4005d823effdfc4b913b.

    One nit inline. I also think the two commits can be squashed when you rebase this.

  66. chris-belcher force-pushed on Aug 27, 2018
  67. DrahtBot removed the label Needs rebase on Aug 27, 2018
  68. chris-belcher commented at 10:37 pm on August 27, 2018: contributor

    Rebased.

    The test has failed but works when I run it locally.

  69. promag commented at 10:42 pm on August 27, 2018: member

    Unrelated build error:

    0...
    1Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [389 kB]
    2Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [2807 B]
    3Fetched 25.9 MB in 8min 28s (50.9 kB/s)
    4Reading package lists...
    5No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
    6Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
    

    Restarted job.

  70. in src/rpc/net.cpp:659 in 668e433211 outdated
    654+        throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
    655+    }
    656+
    657+    int count = 1;
    658+    if (!request.params[0].isNull()) {
    659+        count = request.params[0].get_int();
    


    promag commented at 10:44 pm on August 27, 2018:
    Should validate count > 0? Also, should have a maximum value?

    promag commented at 10:51 pm on August 27, 2018:
    nit, could have a test for for invalid argument.
  71. in test/functional/rpc_net.py:126 in 668e433211 outdated
    121+            msg.addrs.append(addr)
    122+        self.nodes[0].p2p.send_and_ping(msg)
    123+
    124+        # obtain addresses via rpc call and check they were ones sent in before
    125+        NODE_ADDRESSES_REQUEST_COUNT = 10
    126+        node_addresses = self.nodes[0].getnodeaddresses(NODE_ADDRESSES_REQUEST_COUNT)
    


    promag commented at 10:48 pm on August 27, 2018:
    Use named arguments instead of long and verbose variables? Then ditch NODE_ADDRESSES_REQUEST_COUNT.

    promag commented at 10:50 pm on August 27, 2018:
    Could also test that the result is limited by the existing addressed, not by the requested count.

    chris-belcher commented at 12:32 pm on August 31, 2018:

    Unless I’m missing something, that verbose variable is still needed for the assert_equal check in the line after. It seems a better way than having magic numbers. I’ve reduced the length of the variable name though.

    I haven’t put a max value check because it depends on the size of g_connman->GetAddresses at that time. How that max value works is explained in the docs.

  72. in src/rpc/net.cpp:668 in 668e433211 outdated
    663+    UniValue ret(UniValue::VARR);
    664+
    665+    int address_return_count = std::min(count, (int)vAddr.size());
    666+    for (int i = 0; i < address_return_count; ++i) {
    667+        UniValue obj(UniValue::VOBJ);
    668+        CAddress addr = vAddr[i];
    


    promag commented at 10:51 pm on August 27, 2018:
    const CAddress&?
  73. in test/functional/rpc_net.py:130 in 668e433211 outdated
    124+        # obtain addresses via rpc call and check they were ones sent in before
    125+        NODE_ADDRESSES_REQUEST_COUNT = 10
    126+        node_addresses = self.nodes[0].getnodeaddresses(NODE_ADDRESSES_REQUEST_COUNT)
    127+        assert_equal(len(node_addresses), NODE_ADDRESSES_REQUEST_COUNT)
    128+        for a in node_addresses:
    129+            # the timestamps are usually offset by a few hours, so only check existance
    


    promag commented at 10:54 pm on August 27, 2018:
    But could check that value is greater than some value?
  74. in src/rpc/net.cpp:665 in 668e433211 outdated
    660+    }
    661+    // returns a shuffled list of CAddress
    662+    std::vector<CAddress> vAddr = g_connman->GetAddresses();
    663+    UniValue ret(UniValue::VARR);
    664+
    665+    int address_return_count = std::min(count, (int)vAddr.size());
    


    promag commented at 10:54 pm on August 27, 2018:
    Why the cast? Could inline std::min below.
  75. promag commented at 10:58 pm on August 27, 2018: member
    Care to add a release note by creating the file doc/release-notes-13152.md?
  76. chris-belcher force-pushed on Aug 31, 2018
  77. chris-belcher force-pushed on Aug 31, 2018
  78. chris-belcher commented at 12:43 pm on August 31, 2018: contributor
    Thanks for the review @promag. I have created the release notes entry in the style of the release-notes-0.15.0 file.
  79. in src/rpc/net.cpp:665 in e6a6cea8c8 outdated
    659+        count = request.params[0].get_int();
    660+        if (count <= 0)
    661+            throw JSONRPCError(RPC_INVALID_PARAMETER, "Address count out of range");
    662+    }
    663+    // returns a shuffled list of CAddress
    664+    std::vector<CAddress> vAddr = g_connman->GetAddresses();
    


    promag commented at 12:52 pm on August 31, 2018:
    Makes sense to pass the max here?

    chris-belcher commented at 1:00 pm on August 31, 2018:
    Can you rephrase this, I didn’t understand? What would be done with the max? The count parameter is already a bit like a max?

    promag commented at 1:04 pm on August 31, 2018:
    I mean, GetAddresses could return count addresses instead.

    chris-belcher commented at 1:13 pm on August 31, 2018:
    How? GetAddresses doesn’t accept a parameter

    promag commented at 10:26 pm on September 5, 2018:
    Right, I’m asking if it makes sense to add that parameter.

    chris-belcher commented at 12:53 pm on September 6, 2018:
    Ah I see! I think it doesn’t make sense, because GetAddresses is used in a few other places and that change would go against the principle of each PR only doing one thing.

    promag commented at 12:57 pm on September 6, 2018:
    Sounds reasonable.
  80. in test/functional/rpc_net.py:130 in e6a6cea8c8 outdated
    125+        # obtain addresses via rpc call and check they were ones sent in before
    126+        REQUEST_COUNT = 10
    127+        node_addresses = self.nodes[0].getnodeaddresses(REQUEST_COUNT)
    128+        assert_equal(len(node_addresses), REQUEST_COUNT)
    129+        for a in node_addresses:
    130+            # the timestamps are usually offset by a few hours, so only check existance
    


    practicalswift commented at 6:18 pm on September 2, 2018:
    Typo found by codespell: existance
  81. chris-belcher force-pushed on Sep 3, 2018
  82. DrahtBot added the label Needs rebase on Sep 10, 2018
  83. chris-belcher force-pushed on Sep 10, 2018
  84. DrahtBot removed the label Needs rebase on Sep 10, 2018
  85. in test/functional/rpc_net.py:132 in a3fd87909b outdated
    127+        node_addresses = self.nodes[0].getnodeaddresses(REQUEST_COUNT)
    128+        assert_equal(len(node_addresses), REQUEST_COUNT)
    129+        for a in node_addresses:
    130+            # the timestamps are usually offset by a few hours, so only check existence
    131+            assert "time" in a
    132+            assert_greater_than(a["time"], 1527811200) #1st June 2018
    


    practicalswift commented at 2:40 pm on September 11, 2018:

    A very small nit, but to please PEP-8 consider fixing this:

    0./test/functional/rpc_net.py:132:56: E262 inline comment should start with '# '
    

    chris-belcher commented at 6:17 pm on September 13, 2018:
    Done
  86. scravy approved
  87. chris-belcher force-pushed on Sep 13, 2018
  88. in src/rpc/net.cpp:672 in b3512ba706 outdated
    667+    int address_return_count = std::min<int>(count, vAddr.size());
    668+    for (int i = 0; i < address_return_count; ++i) {
    669+        UniValue obj(UniValue::VOBJ);
    670+        const CAddress& addr = vAddr[i];
    671+        obj.pushKV("time", (int)addr.nTime);
    672+        obj.pushKV("services", addr.nServices);
    


    ken2812221 commented at 1:27 pm on September 13, 2018:

    Appveyor error:

    0c:\projects\bitcoin\src\rpc\net.cpp(672): error C2668: 'UniValue::pushKV': ambiguous call to overloaded function
    

    Maybe make it an explicit type?

    0obj.pushKV("services", (uint64_t)addr.nServices);
    
  89. chris-belcher force-pushed on Sep 13, 2018
  90. promag commented at 7:01 pm on September 13, 2018: member
    Looks good to me, utACK 8b96ebe.
  91. in src/rpc/net.cpp:661 in 8b96ebe5e1 outdated
    656+
    657+    int count = 1;
    658+    if (!request.params[0].isNull()) {
    659+        count = request.params[0].get_int();
    660+        if (count <= 0)
    661+            throw JSONRPCError(RPC_INVALID_PARAMETER, "Address count out of range");
    


    jnewbery commented at 8:57 pm on September 13, 2018:
    I’m really sorry to code-style nit when this PR has been through so much review, but all then clauses should be in braces or on the same line (https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c)
  92. jnewbery commented at 9:07 pm on September 13, 2018: member

    Sorry to nit at this late stage. Thanks so much for sticking with this. I know it’s taken a long time!

    One tiny code-style change and I think this is ready for merge.

  93. in test/functional/rpc_net.py:131 in 8b96ebe5e1 outdated
    126+        REQUEST_COUNT = 10
    127+        node_addresses = self.nodes[0].getnodeaddresses(REQUEST_COUNT)
    128+        assert_equal(len(node_addresses), REQUEST_COUNT)
    129+        for a in node_addresses:
    130+            # the timestamps are usually offset by a few hours, so only check existence
    131+            assert "time" in a
    


    promag commented at 9:14 pm on September 13, 2018:
    nit, can be removed — since @jnewbery nit’ed :trollface:
  94. [rpc] Add getnodeaddresses RPC command
    New getnodeaddresses call gives access via RPC to the peers known by
    the node. It may be useful for bitcoin wallets to broadcast their
    transactions over tor for improved privacy without using the
    centralized DNS seeds. getnodeaddresses is very similar to the getaddr
    p2p method.
    
    Tests the new rpc call by feeding IP address to a test node via the p2p
    protocol, then obtaining someone of those addresses with
    getnodeaddresses and checking that they are a subset.
    a2eb6f5405
  95. chris-belcher force-pushed on Sep 17, 2018
  96. chris-belcher commented at 8:57 am on September 18, 2018: contributor
    Fixed those nits
  97. ajtowns commented at 1:28 pm on September 18, 2018: member
    utACK a2eb6f540538d32725aecf678301a96247db6fd9
  98. MarcoFalke commented at 9:25 pm on September 18, 2018: member
    utACK a2eb6f540538d32725aecf678301a96247db6fd9
  99. promag commented at 9:30 pm on September 18, 2018: member
    utACK a2eb6f5. Please fix PR description: “New getaddress call gives …”
  100. MarcoFalke referenced this in commit d26278988f on Sep 18, 2018
  101. MarcoFalke merged this on Sep 18, 2018
  102. MarcoFalke closed this on Sep 18, 2018

  103. chris-belcher deleted the branch on Sep 27, 2018
  104. Munkybooty referenced this in commit f014a5bd91 on Jul 9, 2021
  105. PastaPastaPasta referenced this in commit 6503e1cf0e on Jul 19, 2021
  106. PastaPastaPasta referenced this in commit 13927cf23a on Jul 20, 2021
  107. PastaPastaPasta referenced this in commit 21a895674b on Jul 20, 2021
  108. random-zebra referenced this in commit 69979ce40b on Aug 12, 2021
  109. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me