Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: block tree (simple) #1839

Merged
merged 36 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e3c77dd
explicit type
turuslan Oct 9, 2023
802c67e
root constructor
turuslan Oct 9, 2023
4977a4f
warp mutex
turuslan Oct 9, 2023
b57405c
remove unfinalized
turuslan Oct 9, 2023
80fbae4
remove unused
turuslan Oct 9, 2023
726aaeb
finalized has_justification
turuslan Oct 9, 2023
f351cbb
unused
turuslan Oct 9, 2023
b24810b
block weight
turuslan Oct 9, 2023
19cd0ea
fix test
turuslan Oct 9, 2023
07df715
constructor
turuslan Oct 9, 2023
8431645
meta finalized
turuslan Oct 9, 2023
3b89aee
meta best
turuslan Oct 9, 2023
e43f846
meta leaf count
turuslan Oct 9, 2023
8796ad0
meta leaf hashes
turuslan Oct 9, 2023
a38ecd5
reuse
turuslan Oct 9, 2023
6364ec3
reuse
turuslan Oct 9, 2023
4b130ab
meta is leaf
turuslan Oct 9, 2023
5995ba9
cmp
turuslan Oct 9, 2023
8f60064
can descend
turuslan Oct 9, 2023
0289def
best with
turuslan Oct 9, 2023
b1b99a8
remove leaf
turuslan Oct 9, 2023
091ff94
remove meta
turuslan Oct 9, 2023
90a4e7e
weak ptr
turuslan Oct 9, 2023
50eb803
can descend
turuslan Oct 9, 2023
55948f7
weak parent
turuslan Oct 9, 2023
db8c353
info
turuslan Oct 10, 2023
d30fc38
unused
turuslan Oct 10, 2023
359ce47
find
turuslan Oct 10, 2023
d7f20ed
no shared
turuslan Oct 10, 2023
7917b15
unused
turuslan Oct 10, 2023
f720844
finalize
turuslan Oct 10, 2023
6e99885
finalize justification
turuslan Oct 10, 2023
d3e2bf8
Merge remote-tracking branch 'origin/master' into refactor/block-tree-1
turuslan Oct 10, 2023
525821b
remove unfinalized, reorg and prune
turuslan Oct 10, 2023
f20e71d
return info
turuslan Oct 10, 2023
eaacb72
Merge remote-tracking branch 'origin/master' into k0
turuslan Oct 10, 2023
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
5 changes: 5 additions & 0 deletions core/blockchain/block_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ namespace kagome::blockchain {
* Notify best and finalized block to subscriptions.
*/
virtual void notifyBestAndFinalized() = 0;

/**
* Used when switching from fast-sync to full-sync.
*/
virtual void removeUnfinalized() = 0;
};

} // namespace kagome::blockchain
440 changes: 180 additions & 260 deletions core/blockchain/impl/block_tree_impl.cpp

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion core/blockchain/impl/block_tree_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace kagome::storage::trie_pruner {
}

namespace kagome::blockchain {

struct ReorgAndPrune;
class TreeNode;
class CachedTree;

Expand Down Expand Up @@ -144,6 +144,8 @@ namespace kagome::blockchain {

void notifyBestAndFinalized() override;

void removeUnfinalized() override;

private:
struct BlockTreeData {
std::shared_ptr<BlockHeaderRepository> header_repo_;
Expand Down Expand Up @@ -179,6 +181,9 @@ namespace kagome::blockchain {
std::shared_ptr<storage::trie_pruner::TriePruner> state_pruner,
std::shared_ptr<::boost::asio::io_context> io_context);

outcome::result<void> reorgAndPrune(BlockTreeData &p,
const ReorgAndPrune &changes);

outcome::result<void> pruneNoLock(
BlockTreeData &p, const std::shared_ptr<TreeNode> &lastFinalizedNode);

Expand Down
Loading