Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ void BaseIndex::ThreadSync()
const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
if (!pindex_next) {
m_best_block_index = pindex;
m_synced = true;
// No need to handle errors in Commit. See rationale above.
Commit();
m_synced = true;
break;
}
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ void Shutdown(NodeContext& node)

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

// After the threads that potentially access these pointers have been stopped,
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
}

for (const std::string& strAddNode : lAddresses) {
CService service(LookupNumeric(strAddNode, Params().GetDefaultPort(strAddNode)));
CService service{MaybeFlipIPv6toCJDNS(LookupNumeric(strAddNode, Params().GetDefaultPort(strAddNode)))};
AddedNodeInfo addedNode{strAddNode, CService(), false, false};
if (service.IsValid()) {
// strAddNode is an IP:port
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
UniValue objTx(UniValue::VOBJ);
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity);
txs.push_back(objTx);
txs.push_back(std::move(objTx));
}
break;
}

result.pushKV("tx", txs);
result.pushKV("tx", std::move(txs));

return result;
}
Expand Down
8 changes: 7 additions & 1 deletion src/rpc/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static fs::path GetAuthCookieFile(bool temp=false)
return AbsPathForConfigVal(fs::PathFromString(arg));
}

static bool g_generated_cookie = false;

bool GenerateAuthCookie(std::string *cookie_out)
{
const size_t COOKIE_SIZE = 32;
Expand All @@ -103,6 +105,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
return false;
}
g_generated_cookie = true;
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));

if (cookie_out)
Expand Down Expand Up @@ -168,7 +171,10 @@ bool GetMainchainAuthCookie(std::string *cookie_out)
void DeleteAuthCookie()
{
try {
fs::remove(GetAuthCookieFile());
if (g_generated_cookie) {
// Delete the cookie file if it was generated by this process
fs::remove(GetAuthCookieFile());
}
} catch (const fs::filesystem_error& e) {
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
}
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def run_test(self):
self.log.info("Check that we can't start a second bitcoind instance using the same datadir")
expected_msg = f"Error: Cannot obtain a lock on data directory {datadir}. {self.config['environment']['PACKAGE_NAME']} is probably already running."
self.nodes[1].assert_start_raises_init_error(extra_args=[f'-datadir={self.nodes[0].datadir}', '-noserver'], expected_msg=expected_msg)

cookie_file = datadir + "/.cookie"
assert os.path.isfile(cookie_file) # should not be deleted during the second bitcoind instance shutdown
if self.is_wallet_compiled():
def check_wallet_filelock(descriptors):
wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])
Expand Down