mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
scripted-diff: Replace error() with LogError()
This fixes the log output when -logsourcelocations is used. Also, instead of 'ERROR:', the log will now say '[error]', like other errors logged with LogError. -BEGIN VERIFY SCRIPT- sed -i --regexp-extended 's! error\("([^"]+)"! LogError("\1\\n"!g' $( git grep -l ' error(' ./src/ ) -END VERIFY SCRIPT-
This commit is contained in:
parent
fa808fb749
commit
fad0335517
13 changed files with 97 additions and 97 deletions
|
@ -44,7 +44,7 @@ bool SerializeDB(Stream& stream, const Data& data)
|
||||||
hashwriter << Params().MessageStart() << data;
|
hashwriter << Params().MessageStart() << data;
|
||||||
stream << hashwriter.GetHash();
|
stream << hashwriter.GetHash();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
error("%s: Serialize or I/O error - %s", __func__, e.what());
|
LogError("%s: Serialize or I/O error - %s\n", __func__, e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
|
||||||
if (fileout.IsNull()) {
|
if (fileout.IsNull()) {
|
||||||
fileout.fclose();
|
fileout.fclose();
|
||||||
remove(pathTmp);
|
remove(pathTmp);
|
||||||
error("%s: Failed to open file %s", __func__, fs::PathToString(pathTmp));
|
LogError("%s: Failed to open file %s\n", __func__, fs::PathToString(pathTmp));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
|
||||||
if (!FileCommit(fileout.Get())) {
|
if (!FileCommit(fileout.Get())) {
|
||||||
fileout.fclose();
|
fileout.fclose();
|
||||||
remove(pathTmp);
|
remove(pathTmp);
|
||||||
error("%s: Failed to flush file %s", __func__, fs::PathToString(pathTmp));
|
LogError("%s: Failed to flush file %s\n", __func__, fs::PathToString(pathTmp));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fileout.fclose();
|
fileout.fclose();
|
||||||
|
@ -86,7 +86,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
|
||||||
// replace existing file, if any, with new file
|
// replace existing file, if any, with new file
|
||||||
if (!RenameOver(pathTmp, path)) {
|
if (!RenameOver(pathTmp, path)) {
|
||||||
remove(pathTmp);
|
remove(pathTmp);
|
||||||
error("%s: Rename-into-place failed", __func__);
|
LogError("%s: Rename-into-place failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ bool CBanDB::Write(const banmap_t& banSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& err : errors) {
|
for (const auto& err : errors) {
|
||||||
error("%s", err);
|
LogError("%s\n", err);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,17 +82,17 @@ bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize)
|
||||||
{
|
{
|
||||||
FILE* file = Open(FlatFilePos(pos.nFile, 0)); // Avoid fseek to nPos
|
FILE* file = Open(FlatFilePos(pos.nFile, 0)); // Avoid fseek to nPos
|
||||||
if (!file) {
|
if (!file) {
|
||||||
error("%s: failed to open file %d", __func__, pos.nFile);
|
LogError("%s: failed to open file %d\n", __func__, pos.nFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (finalize && !TruncateFile(file, pos.nPos)) {
|
if (finalize && !TruncateFile(file, pos.nPos)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
error("%s: failed to truncate file %d", __func__, pos.nFile);
|
LogError("%s: failed to truncate file %d\n", __func__, pos.nFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!FileCommit(file)) {
|
if (!FileCommit(file)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
error("%s: failed to commit file %d", __func__, pos.nFile);
|
LogError("%s: failed to commit file %d\n", __func__, pos.nFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DirectoryCommit(m_dir);
|
DirectoryCommit(m_dir);
|
||||||
|
|
|
@ -229,7 +229,7 @@ bool BaseIndex::Commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
error("%s: Failed to commit latest %s state", __func__, GetName());
|
LogError("%s: Failed to commit latest %s state\n", __func__, GetName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -119,7 +119,7 @@ bool BlockFilterIndex::CustomInit(const std::optional<interfaces::BlockKey>& blo
|
||||||
// indicate database corruption or a disk failure, and starting the index would cause
|
// indicate database corruption or a disk failure, and starting the index would cause
|
||||||
// further corruption.
|
// further corruption.
|
||||||
if (m_db->Exists(DB_FILTER_POS)) {
|
if (m_db->Exists(DB_FILTER_POS)) {
|
||||||
error("%s: Cannot read current %s state; index may be corrupted",
|
LogError("%s: Cannot read current %s state; index may be corrupted\n",
|
||||||
__func__, GetName());
|
__func__, GetName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -138,11 +138,11 @@ bool BlockFilterIndex::CustomCommit(CDBBatch& batch)
|
||||||
// Flush current filter file to disk.
|
// Flush current filter file to disk.
|
||||||
AutoFile file{m_filter_fileseq->Open(pos)};
|
AutoFile file{m_filter_fileseq->Open(pos)};
|
||||||
if (file.IsNull()) {
|
if (file.IsNull()) {
|
||||||
error("%s: Failed to open filter file %d", __func__, pos.nFile);
|
LogError("%s: Failed to open filter file %d\n", __func__, pos.nFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!FileCommit(file.Get())) {
|
if (!FileCommit(file.Get())) {
|
||||||
error("%s: Failed to commit filter file %d", __func__, pos.nFile);
|
LogError("%s: Failed to commit filter file %d\n", __func__, pos.nFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,13 +163,13 @@ bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256&
|
||||||
try {
|
try {
|
||||||
filein >> block_hash >> encoded_filter;
|
filein >> block_hash >> encoded_filter;
|
||||||
if (Hash(encoded_filter) != hash) {
|
if (Hash(encoded_filter) != hash) {
|
||||||
error("Checksum mismatch in filter decode.");
|
LogError("Checksum mismatch in filter decode.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
filter = BlockFilter(GetFilterType(), block_hash, std::move(encoded_filter), /*skip_decode_check=*/true);
|
filter = BlockFilter(GetFilterType(), block_hash, std::move(encoded_filter), /*skip_decode_check=*/true);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
error("%s: Failed to deserialize block filter from disk: %s", __func__, e.what());
|
LogError("%s: Failed to deserialize block filter from disk: %s\n", __func__, e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
|
||||||
|
|
||||||
uint256 expected_block_hash = *Assert(block.prev_hash);
|
uint256 expected_block_hash = *Assert(block.prev_hash);
|
||||||
if (read_out.first != expected_block_hash) {
|
if (read_out.first != expected_block_hash) {
|
||||||
error("%s: previous block header belongs to unexpected block %s; expected %s",
|
LogError("%s: previous block header belongs to unexpected block %s; expected %s\n",
|
||||||
__func__, read_out.first.ToString(), expected_block_hash.ToString());
|
__func__, read_out.first.ToString(), expected_block_hash.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -278,14 +278,14 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
|
||||||
|
|
||||||
for (int height = start_height; height <= stop_height; ++height) {
|
for (int height = start_height; height <= stop_height; ++height) {
|
||||||
if (!db_it.GetKey(key) || key.height != height) {
|
if (!db_it.GetKey(key) || key.height != height) {
|
||||||
error("%s: unexpected key in %s: expected (%c, %d)",
|
LogError("%s: unexpected key in %s: expected (%c, %d)\n",
|
||||||
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint256, DBVal> value;
|
std::pair<uint256, DBVal> value;
|
||||||
if (!db_it.GetValue(value)) {
|
if (!db_it.GetValue(value)) {
|
||||||
error("%s: unable to read value in %s at key (%c, %d)",
|
LogError("%s: unable to read value in %s at key (%c, %d)\n",
|
||||||
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -340,11 +340,11 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
|
||||||
const CBlockIndex* stop_index, std::vector<DBVal>& results)
|
const CBlockIndex* stop_index, std::vector<DBVal>& results)
|
||||||
{
|
{
|
||||||
if (start_height < 0) {
|
if (start_height < 0) {
|
||||||
error("%s: start height (%d) is negative", __func__, start_height);
|
LogError("%s: start height (%d) is negative\n", __func__, start_height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (start_height > stop_index->nHeight) {
|
if (start_height > stop_index->nHeight) {
|
||||||
error("%s: start height (%d) is greater than stop height (%d)",
|
LogError("%s: start height (%d) is greater than stop height (%d)\n",
|
||||||
__func__, start_height, stop_index->nHeight);
|
__func__, start_height, stop_index->nHeight);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
|
||||||
|
|
||||||
size_t i = static_cast<size_t>(height - start_height);
|
size_t i = static_cast<size_t>(height - start_height);
|
||||||
if (!db_it->GetValue(values[i])) {
|
if (!db_it->GetValue(values[i])) {
|
||||||
error("%s: unable to read value in %s at key (%c, %d)",
|
LogError("%s: unable to read value in %s at key (%c, %d)\n",
|
||||||
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!db.Read(DBHashKey(block_hash), results[i])) {
|
if (!db.Read(DBHashKey(block_hash), results[i])) {
|
||||||
error("%s: unable to read value in %s at key (%c, %s)",
|
LogError("%s: unable to read value in %s at key (%c, %s)\n",
|
||||||
__func__, index_name, DB_BLOCK_HASH, block_hash.ToString());
|
__func__, index_name, DB_BLOCK_HASH, block_hash.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
|
||||||
read_out.first.ToString(), expected_block_hash.ToString());
|
read_out.first.ToString(), expected_block_hash.ToString());
|
||||||
|
|
||||||
if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
|
if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
|
||||||
error("%s: previous block header not found; expected %s",
|
LogError("%s: previous block header not found; expected %s\n",
|
||||||
__func__, expected_block_hash.ToString());
|
__func__, expected_block_hash.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -246,14 +246,14 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
|
||||||
|
|
||||||
for (int height = start_height; height <= stop_height; ++height) {
|
for (int height = start_height; height <= stop_height; ++height) {
|
||||||
if (!db_it.GetKey(key) || key.height != height) {
|
if (!db_it.GetKey(key) || key.height != height) {
|
||||||
error("%s: unexpected key in %s: expected (%c, %d)",
|
LogError("%s: unexpected key in %s: expected (%c, %d)\n",
|
||||||
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint256, DBVal> value;
|
std::pair<uint256, DBVal> value;
|
||||||
if (!db_it.GetValue(value)) {
|
if (!db_it.GetValue(value)) {
|
||||||
error("%s: unable to read value in %s at key (%c, %d)",
|
LogError("%s: unable to read value in %s at key (%c, %d)\n",
|
||||||
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
__func__, index_name, DB_BLOCK_HEIGHT, height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ bool CoinStatsIndex::CustomRewind(const interfaces::BlockKey& current_tip, const
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
|
||||||
if (!m_chainstate->m_blockman.ReadBlockFromDisk(block, *iter_tip)) {
|
if (!m_chainstate->m_blockman.ReadBlockFromDisk(block, *iter_tip)) {
|
||||||
error("%s: Failed to read block %s from disk",
|
LogError("%s: Failed to read block %s from disk\n",
|
||||||
__func__, iter_tip->GetBlockHash().ToString());
|
__func__, iter_tip->GetBlockHash().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ bool CoinStatsIndex::CustomInit(const std::optional<interfaces::BlockKey>& block
|
||||||
// exist. Any other errors indicate database corruption or a disk
|
// exist. Any other errors indicate database corruption or a disk
|
||||||
// failure, and starting the index would cause further corruption.
|
// failure, and starting the index would cause further corruption.
|
||||||
if (m_db->Exists(DB_MUHASH)) {
|
if (m_db->Exists(DB_MUHASH)) {
|
||||||
error("%s: Cannot read current %s state; index may be corrupted",
|
LogError("%s: Cannot read current %s state; index may be corrupted\n",
|
||||||
__func__, GetName());
|
__func__, GetName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ bool CoinStatsIndex::CustomInit(const std::optional<interfaces::BlockKey>& block
|
||||||
if (block) {
|
if (block) {
|
||||||
DBVal entry;
|
DBVal entry;
|
||||||
if (!LookUpOne(*m_db, *block, entry)) {
|
if (!LookUpOne(*m_db, *block, entry)) {
|
||||||
error("%s: Cannot read current %s state; index may be corrupted",
|
LogError("%s: Cannot read current %s state; index may be corrupted\n",
|
||||||
__func__, GetName());
|
__func__, GetName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ bool CoinStatsIndex::CustomInit(const std::optional<interfaces::BlockKey>& block
|
||||||
uint256 out;
|
uint256 out;
|
||||||
m_muhash.Finalize(out);
|
m_muhash.Finalize(out);
|
||||||
if (entry.muhash != out) {
|
if (entry.muhash != out) {
|
||||||
error("%s: Cannot read current %s state; index may be corrupted",
|
LogError("%s: Cannot read current %s state; index may be corrupted\n",
|
||||||
__func__, GetName());
|
__func__, GetName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
|
||||||
read_out.first.ToString(), expected_block_hash.ToString());
|
read_out.first.ToString(), expected_block_hash.ToString());
|
||||||
|
|
||||||
if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
|
if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
|
||||||
error("%s: previous block header not found; expected %s",
|
LogError("%s: previous block header not found; expected %s\n",
|
||||||
__func__, expected_block_hash.ToString());
|
__func__, expected_block_hash.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,23 +81,23 @@ bool TxIndex::FindTx(const uint256& tx_hash, uint256& block_hash, CTransactionRe
|
||||||
|
|
||||||
AutoFile file{m_chainstate->m_blockman.OpenBlockFile(postx, true)};
|
AutoFile file{m_chainstate->m_blockman.OpenBlockFile(postx, true)};
|
||||||
if (file.IsNull()) {
|
if (file.IsNull()) {
|
||||||
error("%s: OpenBlockFile failed", __func__);
|
LogError("%s: OpenBlockFile failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CBlockHeader header;
|
CBlockHeader header;
|
||||||
try {
|
try {
|
||||||
file >> header;
|
file >> header;
|
||||||
if (fseek(file.Get(), postx.nTxOffset, SEEK_CUR)) {
|
if (fseek(file.Get(), postx.nTxOffset, SEEK_CUR)) {
|
||||||
error("%s: fseek(...) failed", __func__);
|
LogError("%s: fseek(...) failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file >> TX_WITH_WITNESS(tx);
|
file >> TX_WITH_WITNESS(tx);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
error("%s: Deserialize or I/O error - %s", __func__, e.what());
|
LogError("%s: Deserialize or I/O error - %s\n", __func__, e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (tx->GetHash() != tx_hash) {
|
if (tx->GetHash() != tx_hash) {
|
||||||
error("%s: txid mismatch", __func__);
|
LogError("%s: txid mismatch\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
block_hash = header.GetHash();
|
block_hash = header.GetHash();
|
||||||
|
|
|
@ -134,7 +134,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
|
||||||
outputs[key.n] = std::move(coin);
|
outputs[key.n] = std::move(coin);
|
||||||
stats.coins_count++;
|
stats.coins_count++;
|
||||||
} else {
|
} else {
|
||||||
error("%s: unable to read value", __func__);
|
LogError("%s: unable to read value\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pcursor->Next();
|
pcursor->Next();
|
||||||
|
|
|
@ -575,7 +575,7 @@ void CNode::SetAddrLocal(const CService& addrLocalIn) {
|
||||||
AssertLockNotHeld(m_addr_local_mutex);
|
AssertLockNotHeld(m_addr_local_mutex);
|
||||||
LOCK(m_addr_local_mutex);
|
LOCK(m_addr_local_mutex);
|
||||||
if (addrLocal.IsValid()) {
|
if (addrLocal.IsValid()) {
|
||||||
error("Addr local already set for node: %i. Refusing to change from %s to %s", id, addrLocal.ToStringAddrPort(), addrLocalIn.ToStringAddrPort());
|
LogError("Addr local already set for node: %i. Refusing to change from %s to %s\n", id, addrLocal.ToStringAddrPort(), addrLocalIn.ToStringAddrPort());
|
||||||
} else {
|
} else {
|
||||||
addrLocal = addrLocalIn;
|
addrLocal = addrLocalIn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
IntrRecvError recvr;
|
IntrRecvError recvr;
|
||||||
LogPrint(BCLog::NET, "SOCKS5 connecting %s\n", strDest);
|
LogPrint(BCLog::NET, "SOCKS5 connecting %s\n", strDest);
|
||||||
if (strDest.size() > 255) {
|
if (strDest.size() > 255) {
|
||||||
error("Hostname too long");
|
LogError("Hostname too long\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Construct the version identifier/method selection message
|
// Construct the version identifier/method selection message
|
||||||
|
@ -359,7 +359,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pchRet1[0] != SOCKSVersion::SOCKS5) {
|
if (pchRet1[0] != SOCKSVersion::SOCKS5) {
|
||||||
error("Proxy failed to initialize");
|
LogError("Proxy failed to initialize\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pchRet1[1] == SOCKS5Method::USER_PASS && auth) {
|
if (pchRet1[1] == SOCKS5Method::USER_PASS && auth) {
|
||||||
|
@ -367,7 +367,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
std::vector<uint8_t> vAuth;
|
std::vector<uint8_t> vAuth;
|
||||||
vAuth.push_back(0x01); // Current (and only) version of user/pass subnegotiation
|
vAuth.push_back(0x01); // Current (and only) version of user/pass subnegotiation
|
||||||
if (auth->username.size() > 255 || auth->password.size() > 255) {
|
if (auth->username.size() > 255 || auth->password.size() > 255) {
|
||||||
error("Proxy username or password too long");
|
LogError("Proxy username or password too long\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vAuth.push_back(auth->username.size());
|
vAuth.push_back(auth->username.size());
|
||||||
|
@ -378,17 +378,17 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
LogPrint(BCLog::PROXY, "SOCKS5 sending proxy authentication %s:%s\n", auth->username, auth->password);
|
LogPrint(BCLog::PROXY, "SOCKS5 sending proxy authentication %s:%s\n", auth->username, auth->password);
|
||||||
uint8_t pchRetA[2];
|
uint8_t pchRetA[2];
|
||||||
if (InterruptibleRecv(pchRetA, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
|
if (InterruptibleRecv(pchRetA, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
|
||||||
error("Error reading proxy authentication response");
|
LogError("Error reading proxy authentication response\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pchRetA[0] != 0x01 || pchRetA[1] != 0x00) {
|
if (pchRetA[0] != 0x01 || pchRetA[1] != 0x00) {
|
||||||
error("Proxy authentication unsuccessful");
|
LogError("Proxy authentication unsuccessful\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (pchRet1[1] == SOCKS5Method::NOAUTH) {
|
} else if (pchRet1[1] == SOCKS5Method::NOAUTH) {
|
||||||
// Perform no authentication
|
// Perform no authentication
|
||||||
} else {
|
} else {
|
||||||
error("Proxy requested wrong authentication method %02x", pchRet1[1]);
|
LogError("Proxy requested wrong authentication method %02x\n", pchRet1[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<uint8_t> vSocks5;
|
std::vector<uint8_t> vSocks5;
|
||||||
|
@ -409,12 +409,12 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
* error message. */
|
* error message. */
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
error("Error while reading proxy response");
|
LogError("Error while reading proxy response\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pchRet2[0] != SOCKSVersion::SOCKS5) {
|
if (pchRet2[0] != SOCKSVersion::SOCKS5) {
|
||||||
error("Proxy failed to accept request");
|
LogError("Proxy failed to accept request\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pchRet2[1] != SOCKS5Reply::SUCCEEDED) {
|
if (pchRet2[1] != SOCKS5Reply::SUCCEEDED) {
|
||||||
|
@ -423,7 +423,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pchRet2[2] != 0x00) { // Reserved field must be 0
|
if (pchRet2[2] != 0x00) { // Reserved field must be 0
|
||||||
error("Error: malformed proxy response");
|
LogError("Error: malformed proxy response\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t pchRet3[256];
|
uint8_t pchRet3[256];
|
||||||
|
@ -433,7 +433,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
case SOCKS5Atyp::DOMAINNAME: {
|
case SOCKS5Atyp::DOMAINNAME: {
|
||||||
recvr = InterruptibleRecv(pchRet3, 1, g_socks5_recv_timeout, sock);
|
recvr = InterruptibleRecv(pchRet3, 1, g_socks5_recv_timeout, sock);
|
||||||
if (recvr != IntrRecvError::OK) {
|
if (recvr != IntrRecvError::OK) {
|
||||||
error("Error reading from proxy");
|
LogError("Error reading from proxy\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int nRecv = pchRet3[0];
|
int nRecv = pchRet3[0];
|
||||||
|
@ -441,22 +441,22 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
error("Error: malformed proxy response");
|
LogError("Error: malformed proxy response\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (recvr != IntrRecvError::OK) {
|
if (recvr != IntrRecvError::OK) {
|
||||||
error("Error reading from proxy");
|
LogError("Error reading from proxy\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (InterruptibleRecv(pchRet3, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
|
if (InterruptibleRecv(pchRet3, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
|
||||||
error("Error reading from proxy");
|
LogError("Error reading from proxy\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LogPrint(BCLog::NET, "SOCKS5 connected %s\n", strDest);
|
LogPrint(BCLog::NET, "SOCKS5 connected %s\n", strDest);
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
error("Error during SOCKS5 proxy handshake: %s", e.what());
|
LogError("Error during SOCKS5 proxy handshake: %s\n", e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,13 +131,13 @@ bool BlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, s
|
||||||
pindexNew->nTx = diskindex.nTx;
|
pindexNew->nTx = diskindex.nTx;
|
||||||
|
|
||||||
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, consensusParams)) {
|
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, consensusParams)) {
|
||||||
error("%s: CheckProofOfWork failed: %s", __func__, pindexNew->ToString());
|
LogError("%s: CheckProofOfWork failed: %s\n", __func__, pindexNew->ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcursor->Next();
|
pcursor->Next();
|
||||||
} else {
|
} else {
|
||||||
error("%s: failed to read value", __func__);
|
LogError("%s: failed to read value\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -434,7 +434,7 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
|
||||||
for (CBlockIndex* pindex : vSortedByHeight) {
|
for (CBlockIndex* pindex : vSortedByHeight) {
|
||||||
if (m_interrupt) return false;
|
if (m_interrupt) return false;
|
||||||
if (previous_index && pindex->nHeight > previous_index->nHeight + 1) {
|
if (previous_index && pindex->nHeight > previous_index->nHeight + 1) {
|
||||||
error("%s: block index is non-contiguous, index of height %d missing", __func__, previous_index->nHeight + 1);
|
LogError("%s: block index is non-contiguous, index of height %d missing\n", __func__, previous_index->nHeight + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
previous_index = pindex;
|
previous_index = pindex;
|
||||||
|
@ -674,7 +674,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
|
||||||
// Open history file to append
|
// Open history file to append
|
||||||
AutoFile fileout{OpenUndoFile(pos)};
|
AutoFile fileout{OpenUndoFile(pos)};
|
||||||
if (fileout.IsNull()) {
|
if (fileout.IsNull()) {
|
||||||
error("%s: OpenUndoFile failed", __func__);
|
LogError("%s: OpenUndoFile failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,7 +685,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
|
||||||
// Write undo data
|
// Write undo data
|
||||||
long fileOutPos = ftell(fileout.Get());
|
long fileOutPos = ftell(fileout.Get());
|
||||||
if (fileOutPos < 0) {
|
if (fileOutPos < 0) {
|
||||||
error("%s: ftell failed", __func__);
|
LogError("%s: ftell failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pos.nPos = (unsigned int)fileOutPos;
|
pos.nPos = (unsigned int)fileOutPos;
|
||||||
|
@ -705,14 +705,14 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
||||||
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
|
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
|
||||||
|
|
||||||
if (pos.IsNull()) {
|
if (pos.IsNull()) {
|
||||||
error("%s: no undo data available", __func__);
|
LogError("%s: no undo data available\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
AutoFile filein{OpenUndoFile(pos, true)};
|
AutoFile filein{OpenUndoFile(pos, true)};
|
||||||
if (filein.IsNull()) {
|
if (filein.IsNull()) {
|
||||||
error("%s: OpenUndoFile failed", __func__);
|
LogError("%s: OpenUndoFile failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,13 +724,13 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
||||||
verifier >> blockundo;
|
verifier >> blockundo;
|
||||||
filein >> hashChecksum;
|
filein >> hashChecksum;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
error("%s: Deserialize or I/O error - %s", __func__, e.what());
|
LogError("%s: Deserialize or I/O error - %s\n", __func__, e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify checksum
|
// Verify checksum
|
||||||
if (hashChecksum != verifier.GetHash()) {
|
if (hashChecksum != verifier.GetHash()) {
|
||||||
error("%s: Checksum mismatch", __func__);
|
LogError("%s: Checksum mismatch\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,7 +974,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
||||||
// Open history file to append
|
// Open history file to append
|
||||||
AutoFile fileout{OpenBlockFile(pos)};
|
AutoFile fileout{OpenBlockFile(pos)};
|
||||||
if (fileout.IsNull()) {
|
if (fileout.IsNull()) {
|
||||||
error("WriteBlockToDisk: OpenBlockFile failed");
|
LogError("WriteBlockToDisk: OpenBlockFile failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
||||||
// Write block
|
// Write block
|
||||||
long fileOutPos = ftell(fileout.Get());
|
long fileOutPos = ftell(fileout.Get());
|
||||||
if (fileOutPos < 0) {
|
if (fileOutPos < 0) {
|
||||||
error("WriteBlockToDisk: ftell failed");
|
LogError("WriteBlockToDisk: ftell failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pos.nPos = (unsigned int)fileOutPos;
|
pos.nPos = (unsigned int)fileOutPos;
|
||||||
|
@ -1004,7 +1004,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
|
||||||
if (block.GetUndoPos().IsNull()) {
|
if (block.GetUndoPos().IsNull()) {
|
||||||
FlatFilePos _pos;
|
FlatFilePos _pos;
|
||||||
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
|
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
|
||||||
error("ConnectBlock(): FindUndoPos failed");
|
LogError("ConnectBlock(): FindUndoPos failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
|
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
|
||||||
|
@ -1043,7 +1043,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
AutoFile filein{OpenBlockFile(pos, true)};
|
AutoFile filein{OpenBlockFile(pos, true)};
|
||||||
if (filein.IsNull()) {
|
if (filein.IsNull()) {
|
||||||
error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
|
LogError("ReadBlockFromDisk: OpenBlockFile failed for %s\n", pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,19 +1051,19 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
|
||||||
try {
|
try {
|
||||||
filein >> TX_WITH_WITNESS(block);
|
filein >> TX_WITH_WITNESS(block);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
|
LogError("%s: Deserialize or I/O error - %s at %s\n", __func__, e.what(), pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
if (!CheckProofOfWork(block.GetHash(), block.nBits, GetConsensus())) {
|
if (!CheckProofOfWork(block.GetHash(), block.nBits, GetConsensus())) {
|
||||||
error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
LogError("ReadBlockFromDisk: Errors in block header at %s\n", pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signet only: check block solution
|
// Signet only: check block solution
|
||||||
if (GetConsensus().signet_blocks && !CheckSignetBlockSolution(block, GetConsensus())) {
|
if (GetConsensus().signet_blocks && !CheckSignetBlockSolution(block, GetConsensus())) {
|
||||||
error("ReadBlockFromDisk: Errors in block solution at %s", pos.ToString());
|
LogError("ReadBlockFromDisk: Errors in block solution at %s\n", pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1078,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const CBlockIndex& index) co
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (block.GetHash() != index.GetBlockHash()) {
|
if (block.GetHash() != index.GetBlockHash()) {
|
||||||
error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
LogError("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s\n",
|
||||||
index.ToString(), block_pos.ToString());
|
index.ToString(), block_pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1091,7 +1091,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
|
||||||
hpos.nPos -= 8; // Seek back 8 bytes for meta header
|
hpos.nPos -= 8; // Seek back 8 bytes for meta header
|
||||||
AutoFile filein{OpenBlockFile(hpos, true)};
|
AutoFile filein{OpenBlockFile(hpos, true)};
|
||||||
if (filein.IsNull()) {
|
if (filein.IsNull()) {
|
||||||
error("%s: OpenBlockFile failed for %s", __func__, pos.ToString());
|
LogError("%s: OpenBlockFile failed for %s\n", __func__, pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1102,14 +1102,14 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
|
||||||
filein >> blk_start >> blk_size;
|
filein >> blk_start >> blk_size;
|
||||||
|
|
||||||
if (blk_start != GetParams().MessageStart()) {
|
if (blk_start != GetParams().MessageStart()) {
|
||||||
error("%s: Block magic mismatch for %s: %s versus expected %s", __func__, pos.ToString(),
|
LogError("%s: Block magic mismatch for %s: %s versus expected %s\n", __func__, pos.ToString(),
|
||||||
HexStr(blk_start),
|
HexStr(blk_start),
|
||||||
HexStr(GetParams().MessageStart()));
|
HexStr(GetParams().MessageStart()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blk_size > MAX_SIZE) {
|
if (blk_size > MAX_SIZE) {
|
||||||
error("%s: Block data is larger than maximum deserialization size for %s: %s versus %s", __func__, pos.ToString(),
|
LogError("%s: Block data is larger than maximum deserialization size for %s: %s versus %s\n", __func__, pos.ToString(),
|
||||||
blk_size, MAX_SIZE);
|
blk_size, MAX_SIZE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1117,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
|
||||||
block.resize(blk_size); // Zeroing of memory is intentional here
|
block.resize(blk_size); // Zeroing of memory is intentional here
|
||||||
filein.read(MakeWritableByteSpan(block));
|
filein.read(MakeWritableByteSpan(block));
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
error("%s: Read from block file failed: %s for %s", __func__, e.what(), pos.ToString());
|
LogError("%s: Read from block file failed: %s for %s\n", __func__, e.what(), pos.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,7 +1138,7 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight, cons
|
||||||
nBlockSize += static_cast<unsigned int>(BLOCK_SERIALIZATION_HEADER_SIZE);
|
nBlockSize += static_cast<unsigned int>(BLOCK_SERIALIZATION_HEADER_SIZE);
|
||||||
}
|
}
|
||||||
if (!FindBlockPos(blockPos, nBlockSize, nHeight, block.GetBlockTime(), position_known)) {
|
if (!FindBlockPos(blockPos, nBlockSize, nHeight, block.GetBlockTime(), position_known)) {
|
||||||
error("%s: FindBlockPos failed", __func__);
|
LogError("%s: FindBlockPos failed\n", __func__);
|
||||||
return FlatFilePos();
|
return FlatFilePos();
|
||||||
}
|
}
|
||||||
if (!position_known) {
|
if (!position_known) {
|
||||||
|
|
|
@ -158,7 +158,7 @@ bool FillableSigningProvider::GetKey(const CKeyID &address, CKey &keyOut) const
|
||||||
bool FillableSigningProvider::AddCScript(const CScript& redeemScript)
|
bool FillableSigningProvider::AddCScript(const CScript& redeemScript)
|
||||||
{
|
{
|
||||||
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) {
|
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) {
|
||||||
error("FillableSigningProvider::AddCScript(): redeemScripts > %i bytes are invalid", MAX_SCRIPT_ELEMENT_SIZE);
|
LogError("FillableSigningProvider::AddCScript(): redeemScripts > %i bytes are invalid\n", MAX_SCRIPT_ELEMENT_SIZE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_nam
|
||||||
}
|
}
|
||||||
auto lock = std::make_unique<fsbridge::FileLock>(pathLockFile);
|
auto lock = std::make_unique<fsbridge::FileLock>(pathLockFile);
|
||||||
if (!lock->TryLock()) {
|
if (!lock->TryLock()) {
|
||||||
error("Error while attempting to lock directory %s: %s", fs::PathToString(directory), lock->GetReason());
|
LogError("Error while attempting to lock directory %s: %s\n", fs::PathToString(directory), lock->GetReason());
|
||||||
return LockResult::ErrorLock;
|
return LockResult::ErrorLock;
|
||||||
}
|
}
|
||||||
if (!probe_only) {
|
if (!probe_only) {
|
||||||
|
|
|
@ -2045,12 +2045,12 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
|
||||||
|
|
||||||
CBlockUndo blockUndo;
|
CBlockUndo blockUndo;
|
||||||
if (!m_blockman.UndoReadFromDisk(blockUndo, *pindex)) {
|
if (!m_blockman.UndoReadFromDisk(blockUndo, *pindex)) {
|
||||||
error("DisconnectBlock(): failure reading undo data");
|
LogError("DisconnectBlock(): failure reading undo data\n");
|
||||||
return DISCONNECT_FAILED;
|
return DISCONNECT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockUndo.vtxundo.size() + 1 != block.vtx.size()) {
|
if (blockUndo.vtxundo.size() + 1 != block.vtx.size()) {
|
||||||
error("DisconnectBlock(): block and undo data inconsistent");
|
LogError("DisconnectBlock(): block and undo data inconsistent\n");
|
||||||
return DISCONNECT_FAILED;
|
return DISCONNECT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2089,7 +2089,7 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
|
||||||
if (i > 0) { // not coinbases
|
if (i > 0) { // not coinbases
|
||||||
CTxUndo &txundo = blockUndo.vtxundo[i-1];
|
CTxUndo &txundo = blockUndo.vtxundo[i-1];
|
||||||
if (txundo.vprevout.size() != tx.vin.size()) {
|
if (txundo.vprevout.size() != tx.vin.size()) {
|
||||||
error("DisconnectBlock(): transaction and undo data inconsistent");
|
LogError("DisconnectBlock(): transaction and undo data inconsistent\n");
|
||||||
return DISCONNECT_FAILED;
|
return DISCONNECT_FAILED;
|
||||||
}
|
}
|
||||||
for (unsigned int j = tx.vin.size(); j > 0;) {
|
for (unsigned int j = tx.vin.size(); j > 0;) {
|
||||||
|
@ -2222,7 +2222,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||||
// problems.
|
// problems.
|
||||||
return FatalError(m_chainman.GetNotifications(), state, "Corrupt block found indicating potential hardware failure; shutting down");
|
return FatalError(m_chainman.GetNotifications(), state, "Corrupt block found indicating potential hardware failure; shutting down");
|
||||||
}
|
}
|
||||||
error("%s: Consensus::CheckBlock: %s", __func__, state.ToString());
|
LogError("%s: Consensus::CheckBlock: %s\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2409,7 +2409,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||||
// Any transaction validation failure in ConnectBlock is a block consensus failure
|
// Any transaction validation failure in ConnectBlock is a block consensus failure
|
||||||
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
|
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
|
||||||
tx_state.GetRejectReason(), tx_state.GetDebugMessage());
|
tx_state.GetRejectReason(), tx_state.GetDebugMessage());
|
||||||
error("%s: Consensus::CheckTxInputs: %s, %s", __func__, tx.GetHash().ToString(), state.ToString());
|
LogError("%s: Consensus::CheckTxInputs: %s, %s\n", __func__, tx.GetHash().ToString(), state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nFees += txfee;
|
nFees += txfee;
|
||||||
|
@ -2451,7 +2451,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||||
// Any transaction validation failure in ConnectBlock is a block consensus failure
|
// Any transaction validation failure in ConnectBlock is a block consensus failure
|
||||||
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
|
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
|
||||||
tx_state.GetRejectReason(), tx_state.GetDebugMessage());
|
tx_state.GetRejectReason(), tx_state.GetDebugMessage());
|
||||||
error("ConnectBlock(): CheckInputScripts on %s failed with %s",
|
LogError("ConnectBlock(): CheckInputScripts on %s failed with %s\n",
|
||||||
tx.GetHash().ToString(), state.ToString());
|
tx.GetHash().ToString(), state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2826,7 +2826,7 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
|
||||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||||
CBlock& block = *pblock;
|
CBlock& block = *pblock;
|
||||||
if (!m_blockman.ReadBlockFromDisk(block, *pindexDelete)) {
|
if (!m_blockman.ReadBlockFromDisk(block, *pindexDelete)) {
|
||||||
error("DisconnectTip(): Failed to read block");
|
LogError("DisconnectTip(): Failed to read block\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
|
@ -2835,7 +2835,7 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
|
||||||
CCoinsViewCache view(&CoinsTip());
|
CCoinsViewCache view(&CoinsTip());
|
||||||
assert(view.GetBestBlock() == pindexDelete->GetBlockHash());
|
assert(view.GetBestBlock() == pindexDelete->GetBlockHash());
|
||||||
if (DisconnectBlock(block, pindexDelete, view) != DISCONNECT_OK) {
|
if (DisconnectBlock(block, pindexDelete, view) != DISCONNECT_OK) {
|
||||||
error("DisconnectTip(): DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString());
|
LogError("DisconnectTip(): DisconnectBlock %s failed\n", pindexDelete->GetBlockHash().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool flushed = view.Flush();
|
bool flushed = view.Flush();
|
||||||
|
@ -2966,7 +2966,7 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
if (state.IsInvalid())
|
if (state.IsInvalid())
|
||||||
InvalidBlockFound(pindexNew, state);
|
InvalidBlockFound(pindexNew, state);
|
||||||
error("%s: ConnectBlock %s failed, %s", __func__, pindexNew->GetBlockHash().ToString(), state.ToString());
|
LogError("%s: ConnectBlock %s failed, %s\n", __func__, pindexNew->GetBlockHash().ToString(), state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
time_3 = SteadyClock::now();
|
time_3 = SteadyClock::now();
|
||||||
|
@ -4250,7 +4250,7 @@ bool ChainstateManager::AcceptBlock(const std::shared_ptr<const CBlock>& pblock,
|
||||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||||
m_blockman.m_dirty_blockindex.insert(pindex);
|
m_blockman.m_dirty_blockindex.insert(pindex);
|
||||||
}
|
}
|
||||||
error("%s: %s", __func__, state.ToString());
|
LogError("%s: %s\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4314,7 +4314,7 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
|
||||||
if (m_options.signals) {
|
if (m_options.signals) {
|
||||||
m_options.signals->BlockChecked(*block, state);
|
m_options.signals->BlockChecked(*block, state);
|
||||||
}
|
}
|
||||||
error("%s: AcceptBlock FAILED (%s)", __func__, state.ToString());
|
LogError("%s: AcceptBlock FAILED (%s)\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4323,14 +4323,14 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
|
||||||
|
|
||||||
BlockValidationState state; // Only used to report errors, not invalidity - ignore it
|
BlockValidationState state; // Only used to report errors, not invalidity - ignore it
|
||||||
if (!ActiveChainstate().ActivateBestChain(state, block)) {
|
if (!ActiveChainstate().ActivateBestChain(state, block)) {
|
||||||
error("%s: ActivateBestChain failed (%s)", __func__, state.ToString());
|
LogError("%s: ActivateBestChain failed (%s)\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chainstate* bg_chain{WITH_LOCK(cs_main, return BackgroundSyncInProgress() ? m_ibd_chainstate.get() : nullptr)};
|
Chainstate* bg_chain{WITH_LOCK(cs_main, return BackgroundSyncInProgress() ? m_ibd_chainstate.get() : nullptr)};
|
||||||
BlockValidationState bg_state;
|
BlockValidationState bg_state;
|
||||||
if (bg_chain && !bg_chain->ActivateBestChain(bg_state, block)) {
|
if (bg_chain && !bg_chain->ActivateBestChain(bg_state, block)) {
|
||||||
error("%s: [background] ActivateBestChain failed (%s)", __func__, bg_state.ToString());
|
LogError("%s: [background] ActivateBestChain failed (%s)\n", __func__, bg_state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4370,15 +4370,15 @@ bool TestBlockValidity(BlockValidationState& state,
|
||||||
|
|
||||||
// NOTE: CheckBlockHeader is called by CheckBlock
|
// NOTE: CheckBlockHeader is called by CheckBlock
|
||||||
if (!ContextualCheckBlockHeader(block, state, chainstate.m_blockman, chainstate.m_chainman, pindexPrev)) {
|
if (!ContextualCheckBlockHeader(block, state, chainstate.m_blockman, chainstate.m_chainman, pindexPrev)) {
|
||||||
error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, state.ToString());
|
LogError("%s: Consensus::ContextualCheckBlockHeader: %s\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot)) {
|
if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot)) {
|
||||||
error("%s: Consensus::CheckBlock: %s", __func__, state.ToString());
|
LogError("%s: Consensus::CheckBlock: %s\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ContextualCheckBlock(block, state, chainstate.m_chainman, pindexPrev)) {
|
if (!ContextualCheckBlock(block, state, chainstate.m_chainman, pindexPrev)) {
|
||||||
error("%s: Consensus::ContextualCheckBlock: %s", __func__, state.ToString());
|
LogError("%s: Consensus::ContextualCheckBlock: %s\n", __func__, state.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!chainstate.ConnectBlock(block, state, &indexDummy, viewNew, true)) {
|
if (!chainstate.ConnectBlock(block, state, &indexDummy, viewNew, true)) {
|
||||||
|
@ -4584,7 +4584,7 @@ bool Chainstate::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& in
|
||||||
// TODO: merge with ConnectBlock
|
// TODO: merge with ConnectBlock
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
if (!m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||||
error("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
LogError("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4610,7 +4610,7 @@ bool Chainstate::ReplayBlocks()
|
||||||
std::vector<uint256> hashHeads = db.GetHeadBlocks();
|
std::vector<uint256> hashHeads = db.GetHeadBlocks();
|
||||||
if (hashHeads.empty()) return true; // We're already in a consistent state.
|
if (hashHeads.empty()) return true; // We're already in a consistent state.
|
||||||
if (hashHeads.size() != 2) {
|
if (hashHeads.size() != 2) {
|
||||||
error("ReplayBlocks(): unknown inconsistent state");
|
LogError("ReplayBlocks(): unknown inconsistent state\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4622,14 +4622,14 @@ bool Chainstate::ReplayBlocks()
|
||||||
const CBlockIndex* pindexFork = nullptr; // Latest block common to both the old and the new tip.
|
const CBlockIndex* pindexFork = nullptr; // Latest block common to both the old and the new tip.
|
||||||
|
|
||||||
if (m_blockman.m_block_index.count(hashHeads[0]) == 0) {
|
if (m_blockman.m_block_index.count(hashHeads[0]) == 0) {
|
||||||
error("ReplayBlocks(): reorganization to unknown block requested");
|
LogError("ReplayBlocks(): reorganization to unknown block requested\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pindexNew = &(m_blockman.m_block_index[hashHeads[0]]);
|
pindexNew = &(m_blockman.m_block_index[hashHeads[0]]);
|
||||||
|
|
||||||
if (!hashHeads[1].IsNull()) { // The old tip is allowed to be 0, indicating it's the first flush.
|
if (!hashHeads[1].IsNull()) { // The old tip is allowed to be 0, indicating it's the first flush.
|
||||||
if (m_blockman.m_block_index.count(hashHeads[1]) == 0) {
|
if (m_blockman.m_block_index.count(hashHeads[1]) == 0) {
|
||||||
error("ReplayBlocks(): reorganization from unknown block requested");
|
LogError("ReplayBlocks(): reorganization from unknown block requested\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pindexOld = &(m_blockman.m_block_index[hashHeads[1]]);
|
pindexOld = &(m_blockman.m_block_index[hashHeads[1]]);
|
||||||
|
@ -4642,13 +4642,13 @@ bool Chainstate::ReplayBlocks()
|
||||||
if (pindexOld->nHeight > 0) { // Never disconnect the genesis block.
|
if (pindexOld->nHeight > 0) { // Never disconnect the genesis block.
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!m_blockman.ReadBlockFromDisk(block, *pindexOld)) {
|
if (!m_blockman.ReadBlockFromDisk(block, *pindexOld)) {
|
||||||
error("RollbackBlock(): ReadBlockFromDisk() failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
LogError("RollbackBlock(): ReadBlockFromDisk() failed at %d, hash=%s\n", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
|
LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
|
||||||
DisconnectResult res = DisconnectBlock(block, pindexOld, cache);
|
DisconnectResult res = DisconnectBlock(block, pindexOld, cache);
|
||||||
if (res == DISCONNECT_FAILED) {
|
if (res == DISCONNECT_FAILED) {
|
||||||
error("RollbackBlock(): DisconnectBlock failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
LogError("RollbackBlock(): DisconnectBlock failed at %d, hash=%s\n", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// If DISCONNECT_UNCLEAN is returned, it means a non-existing UTXO was deleted, or an existing UTXO was
|
// If DISCONNECT_UNCLEAN is returned, it means a non-existing UTXO was deleted, or an existing UTXO was
|
||||||
|
@ -4768,13 +4768,13 @@ bool Chainstate::LoadGenesisBlock()
|
||||||
const CBlock& block = params.GenesisBlock();
|
const CBlock& block = params.GenesisBlock();
|
||||||
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0, nullptr)};
|
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0, nullptr)};
|
||||||
if (blockPos.IsNull()) {
|
if (blockPos.IsNull()) {
|
||||||
error("%s: writing genesis block to disk failed", __func__);
|
LogError("%s: writing genesis block to disk failed\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CBlockIndex* pindex = m_blockman.AddToBlockIndex(block, m_chainman.m_best_header);
|
CBlockIndex* pindex = m_blockman.AddToBlockIndex(block, m_chainman.m_best_header);
|
||||||
m_chainman.ReceivedBlockTransactions(block, pindex, blockPos);
|
m_chainman.ReceivedBlockTransactions(block, pindex, blockPos);
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
error("%s: failed to write genesis block: %s", __func__, e.what());
|
LogError("%s: failed to write genesis block: %s\n", __func__, e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue