Skip to content

Commit

Permalink
Fix some more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aivve committed May 5, 2024
1 parent c3c78f8 commit e90567e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/CryptoNoteCore/BlockchainCache.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) 2012-2017, The CryptoNote developers, The Bytecoin developers
// Copyright (c) 2014-2018, The Monero Project
// Copyright (c) 2018-2019, The TurtleCoin Developers
// Copyright (c) 2018-2020, The Karbo Developers
// Copyright (c) 2019-2023, The Talleo developers
// Copyright (c) 2017-2024, The Karbo Developers
//
// This file is part of Karbo.
//
Expand Down Expand Up @@ -293,8 +294,9 @@ std::unique_ptr<IBlockchainCache> BlockchainCache::split(uint32_t splitBlockInde
splitMultiSignatureOutputsGlobalIndexes(*newCache, splitBlockIndex);

fixChildrenParent(newCache.get());
newCache->children = children;
children = { newCache.get() };
newCache->children = std::move(children);
children.clear();
children.push_back(newCache.get());

logger(Logging::DEBUGGING) << "Split successfully completed";
return newCache;
Expand Down
24 changes: 15 additions & 9 deletions src/CryptoNoteCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Copyright (c) 2017, The Monero Project
// Copyright (c) 2018, The Galaxia Project Developers
// Copyright (c) 2018-2019, The TurtleCoin Developers
// Copyright (c) 2017-2020, The The Karbo Developers
// Copyright (c) 2019-2023, The Talleo developers
// Copyright (c) 2017-2024, The Karbo Developers
//
// This file is part of Karbo.
//
Expand Down Expand Up @@ -1988,10 +1989,13 @@ IBlockchainCache* Core::findSegmentContainingBlock(uint32_t blockHeight) const {
}

IBlockchainCache* Core::findAlternativeSegmentContainingBlock(const Crypto::Hash& blockHash) const {
IBlockchainCache* cache = nullptr;
std::find_if(++chainsLeaves.begin(), chainsLeaves.end(),
[&](IBlockchainCache* chain) { return cache = findIndexInChain(chain, blockHash); });
return cache;
for (size_t chain = 1; chain < chainsLeaves.size(); ++chain) {
IBlockchainCache* cache = findIndexInChain(chainsLeaves[chain], blockHash);
if (cache != nullptr) {
return cache;
}
}
return nullptr;
}

IBlockchainCache* Core::findMainChainSegmentContainingBlock(const Crypto::Hash& blockHash) const {
Expand All @@ -2002,11 +2006,13 @@ IBlockchainCache* Core::findMainChainSegmentContainingBlock(uint32_t blockIndex)
return findIndexInChain(chainsLeaves[0], blockIndex);
}

// WTF?! this function returns first chain it is able to find..
IBlockchainCache* Core::findAlternativeSegmentContainingBlock(uint32_t blockIndex) const {
IBlockchainCache* cache = nullptr;
std::find_if(++chainsLeaves.begin(), chainsLeaves.end(),
[&](IBlockchainCache* chain) { return cache = findIndexInChain(chain, blockIndex); });
for (size_t chain = 1; chain < chainsLeaves.size(); ++chain) {
IBlockchainCache* cache = findIndexInChain(chainsLeaves[chain], blockIndex);
if (cache != nullptr) {
return cache;
}
}
return nullptr;
}

Expand Down

0 comments on commit e90567e

Please sign in to comment.