Skip to content

Commit

Permalink
#1588 rename variables and remove colored logs
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Jan 18, 2024
1 parent 7c67a04 commit b8cdd8d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
34 changes: 17 additions & 17 deletions libdevcore/LevelDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,17 @@ h256 LevelDB::hashBase() const {
secp256k1_sha256_t ctx;
secp256k1_sha256_initialize( &ctx );
for ( it->SeekToFirst(); it->Valid(); it->Next() ) {
std::string key_ = it->key().ToString();
std::string value_ = it->value().ToString();
std::string keyTmp = it->key().ToString();
std::string valueTmp = it->value().ToString();
// HACK! For backward compatibility! When snapshot could happen between update of two nodes
// - it would lead to stateRoot mismatch
// TODO Move this logic to separate "compatiliblity layer"!
if ( key_ == "pieceUsageBytes" )
if ( keyTmp == "pieceUsageBytes" )
continue;
std::string key_value = key_ + value_;
const std::vector< uint8_t > usc( key_value.begin(), key_value.end() );
bytesConstRef str_key_value( usc.data(), usc.size() );
secp256k1_sha256_write( &ctx, str_key_value.data(), str_key_value.size() );
std::string keyValue = keyTmp + valueTmp;
const std::vector< uint8_t > usc( keyValue.begin(), keyValue.end() );
bytesConstRef strKeyValue( usc.data(), usc.size() );
secp256k1_sha256_write( &ctx, strKeyValue.data(), strKeyValue.size() );
}

h256 hash;
Expand All @@ -268,12 +268,12 @@ h256 LevelDB::hashBaseWithPrefix( char _prefix ) const {
secp256k1_sha256_initialize( &ctx );
for ( it->SeekToFirst(); it->Valid(); it->Next() ) {
if ( it->key()[0] == _prefix ) {
std::string key_ = it->key().ToString();
std::string value_ = it->value().ToString();
std::string key_value = key_ + value_;
const std::vector< uint8_t > usc( key_value.begin(), key_value.end() );
bytesConstRef str_key_value( usc.data(), usc.size() );
secp256k1_sha256_write( &ctx, str_key_value.data(), str_key_value.size() );
std::string keyTmp = it->key().ToString();
std::string valueTmp = it->value().ToString();
std::string keyValue = keyTmp + valueTmp;
const std::vector< uint8_t > usc( keyValue.begin(), keyValue.end() );
bytesConstRef strKeyValue( usc.data(), usc.size() );
secp256k1_sha256_write( &ctx, strKeyValue.data(), strKeyValue.size() );
}
}
h256 hash;
Expand All @@ -294,14 +294,14 @@ void LevelDB::hashBasePartially(
it->SeekToFirst();

for ( size_t counter = 0; it->Valid() && counter < batchSize; it->Next() ) {
std::string key_ = it->key().ToString();
std::string value_ = it->value().ToString();
std::string keyTmp = it->key().ToString();
std::string valueTmp = it->value().ToString();
// HACK! For backward compatibility! When snapshot could happen between update of two nodes
// - it would lead to stateRoot mismatch
// TODO Move this logic to separate "compatiliblity layer"!
if ( key_ == "pieceUsageBytes" )
if ( keyTmp == "pieceUsageBytes" )
continue;
std::string keyValue = key_ + value_;
std::string keyValue = keyTmp + valueTmp;
const std::vector< uint8_t > usc( keyValue.begin(), keyValue.end() );
bytesConstRef strKeyValue( usc.data(), usc.size() );
secp256k1_sha256_write( ctx, strKeyValue.data(), strKeyValue.size() );
Expand Down
19 changes: 8 additions & 11 deletions skaled/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ bool tryDownloadSnapshot( std::shared_ptr< SnapshotManager >& snapshotManager,
try {
snapshotManager->computeSnapshotHash( blockNumber, true );
} catch ( const std::exception& ) {
std::throw_with_nested(
std::runtime_error( cc::fatal( "FATAL:" ) + " " +
cc::error( "Exception while computing snapshot hash " ) ) );
std::throw_with_nested( std::runtime_error(
std::string( "FATAL:" ) +
std::string( " Exception while computing snapshot hash " ) ) );
}

dev::h256 calculated_hash = snapshotManager->getSnapshotHash( blockNumber );
Expand All @@ -449,18 +449,15 @@ bool tryDownloadSnapshot( std::shared_ptr< SnapshotManager >& snapshotManager,
successfullDownload = true;
if ( isRegularSnapshot ) {
snapshotManager->restoreSnapshot( blockNumber );
std::cout << cc::success( "Snapshot restore success for block " )
<< cc::u( to_string( blockNumber ) ) << std::endl;
std::cout << "Snapshot restore success for block " << to_string( blockNumber )
<< std::endl;
}
return successfullDownload;
} else {
clog( VerbosityWarning, "tryDownloadSnapshot" )
<< cc::notice(
"Downloaded snapshot with incorrect hash! Incoming "
"hash " )
<< cc::notice( votedHash.first.hex() )
<< cc::notice( " is not equal to calculated hash " )
<< cc::notice( calculated_hash.hex() ) << cc::notice( " Will try again" );
<< "Downloaded snapshot with incorrect hash! Incoming hash "
<< votedHash.first.hex() << " is not equal to calculated hash "
<< calculated_hash.hex() << " Will try again";
if ( isRegularSnapshot )
snapshotManager->cleanup();
else
Expand Down

0 comments on commit b8cdd8d

Please sign in to comment.