Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
4e54dfac
Commit
4e54dfac
authored
5 years ago
by
Arkadiy Paronyan
Committed by
Gavin Wood
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improved cache documentation (#4067)
parent
38ac5343
Branches
gh-readonly-queue/master/pr-6599-569ce71e2c759b26601608f145d9b5efcb906919
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/core/client/db/src/storage_cache.rs
+6
-6
6 additions, 6 deletions
substrate/core/client/db/src/storage_cache.rs
with
6 additions
and
6 deletions
substrate/core/client/db/src/storage_cache.rs
+
6
−
6
View file @
4e54dfac
...
...
@@ -155,13 +155,12 @@ impl<B: BlockT, H: Hasher> Cache<B, H> {
/// Synchronize the shared cache with the best block state.
/// This function updates the shared cache by removing entries
/// that are invalidated by chain reorganization. It should be
///
be c
all
ed
when chain reorg happens without importing a new block.
/// that are invalidated by chain reorganization. It should be
called
///
extern
all
y
when chain reorg happens without importing a new block.
pub
fn
sync
(
&
mut
self
,
enacted
:
&
[
B
::
Hash
],
retracted
:
&
[
B
::
Hash
])
{
trace!
(
"Syncing shared cache, enacted = {:?}, retracted = {:?}"
,
enacted
,
retracted
);
// Purge changes from re-enacted and retracted blocks.
// Filter out commiting block if any.
let
mut
clear
=
false
;
for
block
in
enacted
{
clear
=
clear
||
{
...
...
@@ -313,6 +312,7 @@ impl<H: Hasher, B: BlockT> CacheChanges<H, B> {
let
is_best
=
is_best
();
trace!
(
"Syncing cache, id = (#{:?}, {:?}), parent={:?}, best={}"
,
commit_number
,
commit_hash
,
self
.parent_hash
,
is_best
);
let
cache
=
&
mut
*
cache
;
// Filter out commiting block if any.
let
enacted
:
Vec
<
_
>
=
enacted
.iter
()
.filter
(|
h
|
commit_hash
.as_ref
()
.map_or
(
true
,
|
p
|
*
h
!=
p
))
...
...
@@ -370,7 +370,7 @@ impl<H: Hasher, B: BlockT> CacheChanges<H, B> {
modifications
.insert
(
k
);
}
// Save modified storage. These are ordered by the block number.
// Save modified storage. These are ordered by the block number
in reverse
.
let
block_changes
=
BlockChanges
{
storage
:
modifications
,
child_storage
:
child_modifications
,
...
...
@@ -427,10 +427,10 @@ impl<H: Hasher, S: StateBackend<H>, B: BlockT> CachingState<H, S, B> {
}
Some
(
ref
parent
)
=>
parent
,
};
// Ignore all storage modified in later blocks
// Ignore all storage
entries
modified in later blocks
.
// Modifications contains block ordered by the number
// We search for our parent in that list first and then for
// all its parent until we hit the canonical block,
// all its parent
s
until we hit the canonical block,
// checking against all the intermediate modifications.
for
m
in
modifications
{
if
&
m
.hash
==
parent
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment