Skip to content

Commit

Permalink
Peer preferentially with NODE_CASH nodes
Browse files Browse the repository at this point in the history
Summary:
Add NODE_BITCOIN_CASH to required services for outbound
peer connections.
Not required for inbound peers.

Test Plan:
- Remove peers.dat
- Start up node
- Monitor peer connections using e.g.
    $ bitcoin-cli getpeerinfo | egrep '(service|subver|inbound)'
- Check that all peers for which inbound is false have bit 5
  (0x20) set in their reported services
- Connect to various other types of peers (BU, Classic, XT)
  using `addnode` and check that connections are successful
- Check that inbound peers without NODE_CASH service bit set
  can connect (you should get occasional crawlers or Satoshi
  clients connecting with services < 0x20)

Reviewers: #bitcoin_abc, deadalnix, CCulianu

Reviewed By: #bitcoin_abc, CCulianu

Subscribers: CCulianu

Differential Revision: https://reviews.bitcoinabc.org/D457
  • Loading branch information
ftrader committed Aug 10, 2017
1 parent c16aa31 commit d68e7e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,9 @@ bool AppInitParameterInteraction(Config &config) {
// to differentiate the network nodes.
nLocalServices = ServiceFlags(nLocalServices | NODE_BITCOIN_CASH);

// Preferentially keep peers which service NODE_BITCOIN_CASH
nRelevantServices = ServiceFlags(nRelevantServices | NODE_BITCOIN_CASH);

nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);

if (mapMultiArgs.count("-bip9params")) {
Expand Down
3 changes: 2 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ static const bool DEFAULT_FORCEDNSSEED = true;
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;

static const ServiceFlags REQUIRED_SERVICES = NODE_NETWORK;
static const ServiceFlags REQUIRED_SERVICES =
ServiceFlags(NODE_NETWORK | NODE_BITCOIN_CASH);

// Default 24-hour ban.
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
Expand Down

0 comments on commit d68e7e4

Please sign in to comment.