Skip to content

Commit 19b52eb

Browse files
committed
Fix build: multiple files
- Error: PoissonNextSend undefined - Fix: Added PoissonNextSend declaration to net.h and implementation to net.cpp - Error: fPruneMode undefined - Fix: Removed fPruneMode references (now handled in BlockManager options) - Error: LoadAddrman undefined - Fix: Added missing addrdb.h include - Error: CTxMemPool constructor mismatch - Fix: Updated to use CTxMemPool::Options struct - Error: pblocktree undefined - Fix: Removed pblocktree.reset() (removed in v26.2) - Error: OMITTED_NAMED_ARG in RPCArg - Fix: Changed to OMITTED (v26.2 naming) - Preserves: Dandelion++ functionality
1 parent 5b75d20 commit 19b52eb

4 files changed

Lines changed: 51 additions & 16 deletions

File tree

src/init.cpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <kernel/mempool_persist.h>
1515
#include <kernel/validation_cache_sizes.h>
1616

17+
#include <addrdb.h>
1718
#include <addrman.h>
1819
#include <banman.h>
1920
#include <blockfilter.h>
@@ -342,7 +343,7 @@ void Shutdown(NodeContext& node)
342343
chainstate->ResetCoinsViews();
343344
}
344345
}
345-
pblocktree.reset();
346+
// pblocktree removed in v26.2 - now managed by BlockManager
346347
}
347348
for (const auto& client : node.chain_clients) {
348349
client->stop();
@@ -875,8 +876,6 @@ bool AppInitBasicSetup(const ArgsManager& args, std::atomic<int>& exit_status)
875876
if (!args.GetBoolArg("-sysperms", false)) {
876877
umask(077);
877878
}
878-
879-
#ifndef WIN32
880879
// Clean shutdown on SIGTERM
881880
registerSignalHandler(SIGTERM, HandleSIGTERM);
882881
registerSignalHandler(SIGINT, HandleSIGTERM);
@@ -1064,13 +1063,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10641063
if (nPruneArg == 1) { // manual pruning: -prune=1
10651064
LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
10661065
nPruneTarget = std::numeric_limits<uint64_t>::max();
1067-
fPruneMode = true;
1066+
// fPruneMode is set via BlockManager options in v26.2
10681067
} else if (nPruneTarget) {
10691068
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
10701069
return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
10711070
}
10721071
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024);
1073-
fPruneMode = true;
1072+
// fPruneMode is set via BlockManager options in v26.2
10741073
}
10751074

10761075
nConnectTimeout = args.GetIntArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
@@ -1123,8 +1122,9 @@ bool AppInitParameterInteraction(const ArgsManager& args)
11231122
if (!chainman_result) {
11241123
return InitError(util::ErrorString(chainman_result));
11251124
}
1126-
BlockManager::Options blockman_opts_dummy{
1125+
node::BlockManager::Options blockman_opts_dummy{
11271126
.chainparams = chainman_opts_dummy.chainparams,
1127+
.prune_target = nPruneTarget,
11281128
.blocks_dir = args.GetBlocksDirPath(),
11291129
.notifications = chainman_opts_dummy.notifications,
11301130
};
@@ -1371,11 +1371,20 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13711371
// Initialize mempool
13721372
assert(!node.mempool);
13731373
int check_ratio = std::min<int>(std::max<int>(args.GetIntArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
1374-
node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), check_ratio);
1374+
1375+
CTxMemPool::Options mempool_opts{
1376+
.estimator = node.fee_estimator.get(),
1377+
.check_ratio = check_ratio,
1378+
};
1379+
node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
13751380

13761381
// Initialize DigiByte stempool for Dandelion++ privacy protocol
13771382
assert(!node.stempool);
1378-
node.stempool = std::make_unique<CTxMemPool>(nullptr, 0, true);
1383+
CTxMemPool::Options stempool_opts{
1384+
.estimator = nullptr,
1385+
.check_ratio = 0,
1386+
};
1387+
node.stempool = std::make_unique<CTxMemPool>(stempool_opts);
13791388

13801389
// Check port numbers
13811390
for (const std::string port_option : {
@@ -1539,7 +1548,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15391548

15401549
// Read asmap file if configured
15411550
if (args.IsArgSet("-asmap")) {
1542-
fs::path asmap_path = fs::path(args.GetArg("-asmap", ""));
1551+
fs::path asmap_path = fs::PathFromString(args.GetArg("-asmap", ""));
15431552
if (asmap_path.empty()) {
15441553
asmap_path = DEFAULT_ASMAP_FILENAME;
15451554
}
@@ -1550,13 +1559,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15501559
InitError(strprintf(_("Could not find asmap file %s"), asmap_path));
15511560
return false;
15521561
}
1553-
std::vector<bool> asmap = CAddrMan::DecodeAsmap(asmap_path);
1562+
std::vector<bool> asmap = DecodeAsmap(asmap_path);
15541563
if (asmap.size() == 0) {
15551564
InitError(strprintf(_("Could not parse asmap file %s"), asmap_path));
15561565
return false;
15571566
}
1558-
const uint256 asmap_version = SerializeHash(asmap);
1559-
node.connman->SetAsmap(std::move(asmap));
1567+
const uint256 asmap_version = (HashWriter{} << asmap).GetHash();
1568+
// asmap is now passed via netgroupman in v26.2
15601569
LogPrintf("Using asmap version %s for IP bucketing\n", asmap_version.ToString());
15611570
} else {
15621571
LogPrintf("Using /16 prefix for IP bucketing\n");
@@ -1588,8 +1597,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15881597
};
15891598
Assert(ApplyArgsManOptions(args, chainman_opts)); // no error can happen, already checked in AppInitParameterInteraction
15901599

1591-
BlockManager::Options blockman_opts{
1600+
node::BlockManager::Options blockman_opts{
15921601
.chainparams = chainman_opts.chainparams,
1602+
.prune_target = nPruneTarget,
15931603
.blocks_dir = args.GetBlocksDirPath(),
15941604
.notifications = chainman_opts.notifications,
15951605
};
@@ -1729,7 +1739,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17291739
assert(!node.peerman);
17301740
node.peerman = PeerManager::make(*node.connman, *node.addrman,
17311741
node.banman.get(), chainman,
1732-
*node.mempool, peerman_opts);
1742+
*node.mempool, *node.stempool, peerman_opts);
17331743
RegisterValidationInterface(node.peerman.get());
17341744

17351745
// ********************************************************* Step 8: start indexers

src/net.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,6 +3826,23 @@ bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func)
38263826
return found != nullptr && NodeFullyConnected(found) && func(found);
38273827
}
38283828

3829+
std::chrono::microseconds CConnman::PoissonNextSendInbound(std::chrono::microseconds now, std::chrono::seconds average_interval)
3830+
{
3831+
if (m_next_send_inv_to_incoming.load() < now) {
3832+
// If this function were called from multiple threads simultaneously
3833+
// it would possible that both update the next send variable, and return a different result to their caller.
3834+
// This is not possible in practice as only the net processing thread invokes this function.
3835+
m_next_send_inv_to_incoming = PoissonNextSend(now, average_interval);
3836+
}
3837+
return m_next_send_inv_to_incoming;
3838+
}
3839+
3840+
std::chrono::microseconds PoissonNextSend(std::chrono::microseconds now, std::chrono::seconds average_interval)
3841+
{
3842+
double unscaled = -log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */);
3843+
return now + std::chrono::duration_cast<std::chrono::microseconds>(unscaled * average_interval + 0.5us);
3844+
}
3845+
38293846
CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id) const
38303847
{
38313848
return CSipHasher(nSeed0, nSeed1).Write(id);

src/net.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,9 @@ class CConnman
12711271
/** Get a unique deterministic randomizer. */
12721272
CSipHasher GetDeterministicRandomizer(uint64_t id) const;
12731273

1274+
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
1275+
std::chrono::microseconds PoissonNextSendInbound(std::chrono::microseconds now, std::chrono::seconds average_interval);
1276+
12741277
void WakeMessageHandler() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
12751278

12761279
/** Return true if we should disconnect the peer for failing an inactivity check. */
@@ -1563,6 +1566,8 @@ class CConnman
15631566
*/
15641567
std::atomic_bool m_start_extra_block_relay_peers{false};
15651568

1569+
std::atomic<std::chrono::microseconds> m_next_send_inv_to_incoming{0us};
1570+
15661571
/**
15671572
* A vector of -bind=<address>:<port>=onion arguments each of which is
15681573
* an address and port that are designated for incoming Tor connections.
@@ -1684,6 +1689,9 @@ class CConnman
16841689
friend struct ConnmanTestMsg;
16851690
};
16861691

1692+
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
1693+
std::chrono::microseconds PoissonNextSend(std::chrono::microseconds now, std::chrono::seconds average_interval);
1694+
16871695
/** Defaults to `CaptureMessageToFile()`, but can be overridden by unit tests. */
16881696
extern std::function<void(const CAddress& addr,
16891697
const std::string& msg_type,

src/rpc/rawtransaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static RPCHelpMan getrawtransaction()
275275
{
276276
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
277277
{"verbosity", RPCArg::Type::NUM, RPCArg::Default{0}, "0 for hex-encoded data, 1 for a JSON object, and 2 for JSON object with fee and prevout"},
278-
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED_NAMED_ARG, "The block in which to look for the transaction"},
278+
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "The block in which to look for the transaction"},
279279
},
280280
{
281281
RPCResult{"if verbosity is not set or set to 0",
@@ -323,7 +323,7 @@ static RPCHelpMan getrawtransaction()
323323
}},
324324
}},
325325
}},
326-
)
326+
}},
327327
},
328328
RPCExamples{
329329
HelpExampleCli("getrawtransaction", "\"mytxid\"")

0 commit comments

Comments
 (0)