Skip to content

Commit 67cd78d

Browse files
authored
Merge pull request #1451 from tomt1664/v25+_cherry_pick
Selected Bitcoin v25 and onwards patches
2 parents 73760ba + 8614ff4 commit 67cd78d

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

src/index/base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ void BaseIndex::ThreadSync()
151151
const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
152152
if (!pindex_next) {
153153
m_best_block_index = pindex;
154-
m_synced = true;
155154
// No need to handle errors in Commit. See rationale above.
156155
Commit();
156+
m_synced = true;
157157
break;
158158
}
159159
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ void Shutdown(NodeContext& node)
238238

239239
// After everything has been shut down, but before things get flushed, stop the
240240
// CScheduler/checkqueue, scheduler and load block thread.
241+
if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join();
241242
if (node.scheduler) node.scheduler->stop();
242243
if (node.reverification_scheduler) node.reverification_scheduler->stop();
243-
if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join();
244244
StopScriptCheckWorkerThreads();
245245

246246
// After the threads that potentially access these pointers have been stopped,

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
22212221
}
22222222

22232223
for (const std::string& strAddNode : lAddresses) {
2224-
CService service(LookupNumeric(strAddNode, Params().GetDefaultPort(strAddNode)));
2224+
CService service{MaybeFlipIPv6toCJDNS(LookupNumeric(strAddNode, Params().GetDefaultPort(strAddNode)))};
22252225
AddedNodeInfo addedNode{strAddNode, CService(), false, false};
22262226
if (service.IsValid()) {
22272227
// strAddNode is an IP:port

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,12 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
279279
const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
280280
UniValue objTx(UniValue::VOBJ);
281281
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity);
282-
txs.push_back(objTx);
282+
txs.push_back(std::move(objTx));
283283
}
284284
break;
285285
}
286286

287-
result.pushKV("tx", txs);
287+
result.pushKV("tx", std::move(txs));
288288

289289
return result;
290290
}

src/rpc/request.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static fs::path GetAuthCookieFile(bool temp=false)
7878
return AbsPathForConfigVal(fs::PathFromString(arg));
7979
}
8080

81+
static bool g_generated_cookie = false;
82+
8183
bool GenerateAuthCookie(std::string *cookie_out)
8284
{
8385
const size_t COOKIE_SIZE = 32;
@@ -103,6 +105,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
103105
LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
104106
return false;
105107
}
108+
g_generated_cookie = true;
106109
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));
107110

108111
if (cookie_out)
@@ -168,7 +171,10 @@ bool GetMainchainAuthCookie(std::string *cookie_out)
168171
void DeleteAuthCookie()
169172
{
170173
try {
171-
fs::remove(GetAuthCookieFile());
174+
if (g_generated_cookie) {
175+
// Delete the cookie file if it was generated by this process
176+
fs::remove(GetAuthCookieFile());
177+
}
172178
} catch (const fs::filesystem_error& e) {
173179
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
174180
}

test/functional/feature_filelock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def run_test(self):
2727
self.log.info("Check that we can't start a second bitcoind instance using the same datadir")
2828
expected_msg = f"Error: Cannot obtain a lock on data directory {datadir}. {self.config['environment']['PACKAGE_NAME']} is probably already running."
2929
self.nodes[1].assert_start_raises_init_error(extra_args=[f'-datadir={self.nodes[0].datadir}', '-noserver'], expected_msg=expected_msg)
30-
30+
cookie_file = datadir + "/.cookie"
31+
assert os.path.isfile(cookie_file) # should not be deleted during the second bitcoind instance shutdown
3132
if self.is_wallet_compiled():
3233
def check_wallet_filelock(descriptors):
3334
wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])

0 commit comments

Comments
 (0)