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
64267000
Verified
Commit
64267000
authored
2 months ago
by
Michal Kucharczyk
Browse files
Options
Downloads
Patches
Plain Diff
view_store: finality_stall_view_cleanup added
parent
a511601f
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs
+41
-4
41 additions, 4 deletions
...ient/transaction-pool/src/fork_aware_txpool/view_store.rs
with
41 additions
and
4 deletions
substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs
+
41
−
4
View file @
64267000
...
...
@@ -27,17 +27,18 @@ use crate::{
graph
::{
self
,
base_pool
::{
TimedTransactionSource
,
Transaction
},
BaseSubmitOutcome
,
ExtrinsicFor
,
ExtrinsicHash
,
TransactionFor
,
ValidatedPoolSubmitOutcome
,
BaseSubmitOutcome
,
BlockHash
,
ExtrinsicFor
,
ExtrinsicHash
,
TransactionFor
,
ValidatedPoolSubmitOutcome
,
},
ReadyIteratorFor
,
LOG_TARGET
,
};
use
itertools
::
Itertools
;
use
parking_lot
::
RwLock
;
use
sc_transaction_pool_api
::{
error
::
Error
as
PoolError
,
PoolStatus
,
TxInvalidityReportMap
};
use
sp_blockchain
::
TreeRoute
;
use
sp_blockchain
::
{
HashAndNumber
,
TreeRoute
}
;
use
sp_runtime
::{
generic
::
BlockId
,
traits
::
Block
as
BlockT
,
traits
::
{
Block
as
BlockT
,
Saturating
},
transaction_validity
::{
InvalidTransaction
,
TransactionValidityError
},
};
use
std
::{
...
...
@@ -595,7 +596,7 @@ where
);
self
.listener
.remove_stale_controllers
();
self
.dropped_stream_controller
.remove_
finalized_tx
s
(
finalized_xts
.clone
());
self
.dropped_stream_controller
.remove_
transaction
s
(
finalized_xts
.clone
());
self
.listener
.remove_view
(
finalized_hash
);
for
view
in
dropped_views
{
...
...
@@ -864,4 +865,40 @@ where
removed
}
/// Clears stale views when blockchain finality stalls.
///
/// This function removes outdated active and inactive views based on the block height
/// difference compared to the current block's height. Views are considered stale and
/// purged from the `ViewStore` if their height difference from the current block `at`
/// exceeds the specified `threshold`.
///
/// If any views are removed, corresponding cleanup operations are performed on multi-view
/// stream controllers to ensure views are also removed there.
pub
(
crate
)
fn
finality_stall_view_cleanup
(
&
self
,
at
:
&
HashAndNumber
<
Block
>
,
threshold
:
usize
)
{
let
mut
dropped_views
=
vec!
[];
{
let
mut
active_views
=
self
.active_views
.write
();
let
mut
inactive_views
=
self
.inactive_views
.write
();
let
mut
f
=
|
hash
:
&
BlockHash
<
ChainApi
>
,
v
:
&
View
<
ChainApi
>
|
->
bool
{
let
diff
=
at
.number
.saturating_sub
(
v
.at.number
);
if
diff
.into
()
>
threshold
.into
()
{
dropped_views
.push
(
*
hash
);
false
}
else
{
true
}
};
active_views
.retain
(|
h
,
v
|
f
(
h
,
v
));
inactive_views
.retain
(|
h
,
v
|
f
(
h
,
v
));
}
if
!
dropped_views
.is_empty
()
{
for
view
in
dropped_views
{
self
.listener
.remove_view
(
view
);
self
.dropped_stream_controller
.remove_view
(
view
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Michal Kucharczyk
@michalkucharczyk
mentioned in commit
24a4b55e
·
1 month ago
mentioned in commit
24a4b55e
mentioned in commit 24a4b55efc067c7d382aeda03f58e20e0b106523
Toggle commit list
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