mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge pull request #1451 from tomt1664/v25+_cherry_pick
Selected Bitcoin v25 and onwards patches
This commit is contained in:
commit
67cd78dbc2
6 changed files with 14 additions and 7 deletions
|
|
@ -151,9 +151,9 @@ void BaseIndex::ThreadSync()
|
||||||
const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
|
const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
|
||||||
if (!pindex_next) {
|
if (!pindex_next) {
|
||||||
m_best_block_index = pindex;
|
m_best_block_index = pindex;
|
||||||
m_synced = true;
|
|
||||||
// No need to handle errors in Commit. See rationale above.
|
// No need to handle errors in Commit. See rationale above.
|
||||||
Commit();
|
Commit();
|
||||||
|
m_synced = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {
|
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {
|
||||||
|
|
|
||||||
|
|
@ -238,9 +238,9 @@ void Shutdown(NodeContext& node)
|
||||||
|
|
||||||
// After everything has been shut down, but before things get flushed, stop the
|
// After everything has been shut down, but before things get flushed, stop the
|
||||||
// CScheduler/checkqueue, scheduler and load block thread.
|
// 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.scheduler) node.scheduler->stop();
|
||||||
if (node.reverification_scheduler) node.reverification_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();
|
StopScriptCheckWorkerThreads();
|
||||||
|
|
||||||
// After the threads that potentially access these pointers have been stopped,
|
// After the threads that potentially access these pointers have been stopped,
|
||||||
|
|
|
||||||
|
|
@ -2221,7 +2221,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::string& strAddNode : lAddresses) {
|
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};
|
AddedNodeInfo addedNode{strAddNode, CService(), false, false};
|
||||||
if (service.IsValid()) {
|
if (service.IsValid()) {
|
||||||
// strAddNode is an IP:port
|
// strAddNode is an IP:port
|
||||||
|
|
|
||||||
|
|
@ -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;
|
const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
|
||||||
UniValue objTx(UniValue::VOBJ);
|
UniValue objTx(UniValue::VOBJ);
|
||||||
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity);
|
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity);
|
||||||
txs.push_back(objTx);
|
txs.push_back(std::move(objTx));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.pushKV("tx", txs);
|
result.pushKV("tx", std::move(txs));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,8 @@ static fs::path GetAuthCookieFile(bool temp=false)
|
||||||
return AbsPathForConfigVal(fs::PathFromString(arg));
|
return AbsPathForConfigVal(fs::PathFromString(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool g_generated_cookie = false;
|
||||||
|
|
||||||
bool GenerateAuthCookie(std::string *cookie_out)
|
bool GenerateAuthCookie(std::string *cookie_out)
|
||||||
{
|
{
|
||||||
const size_t COOKIE_SIZE = 32;
|
const size_t COOKIE_SIZE = 32;
|
||||||
|
|
@ -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));
|
LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
g_generated_cookie = true;
|
||||||
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));
|
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));
|
||||||
|
|
||||||
if (cookie_out)
|
if (cookie_out)
|
||||||
|
|
@ -168,7 +171,10 @@ bool GetMainchainAuthCookie(std::string *cookie_out)
|
||||||
void DeleteAuthCookie()
|
void DeleteAuthCookie()
|
||||||
{
|
{
|
||||||
try {
|
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) {
|
} catch (const fs::filesystem_error& e) {
|
||||||
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
|
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ class FilelockTest(BitcoinTestFramework):
|
||||||
self.log.info("Check that we can't start a second bitcoind instance using the same datadir")
|
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."
|
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)
|
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():
|
if self.is_wallet_compiled():
|
||||||
def check_wallet_filelock(descriptors):
|
def check_wallet_filelock(descriptors):
|
||||||
wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])
|
wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue