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
406c37b5
Verified
Commit
406c37b5
authored
5 months ago
by
Michal Kucharczyk
Browse files
Options
Downloads
Patches
Plain Diff
dropped_watcher: rename C -> ChainApi
parent
c9f2d393
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/dropped_watcher.rs
+29
-26
29 additions, 26 deletions
...transaction-pool/src/fork_aware_txpool/dropped_watcher.rs
with
29 additions
and
26 deletions
substrate/client/transaction-pool/src/fork_aware_txpool/dropped_watcher.rs
+
29
−
26
View file @
406c37b5
...
...
@@ -24,7 +24,7 @@
use
crate
::{
common
::
log_xt
::
log_xt_trace
,
fork_aware_txpool
::
stream_map_util
::
next_event
,
graph
::{
BlockHash
,
ChainApi
,
ExtrinsicHash
},
graph
::{
self
,
BlockHash
,
ExtrinsicHash
},
LOG_TARGET
,
};
use
futures
::
stream
::
StreamExt
;
...
...
@@ -59,24 +59,24 @@ type Controller<T> = mpsc::TracingUnboundedSender<T>;
type
CommandReceiver
<
T
>
=
mpsc
::
TracingUnboundedReceiver
<
T
>
;
/// Commands to control the instance of dropped transactions stream [`StreamOfDropped`].
enum
Command
<
C
>
enum
Command
<
C
hainApi
>
where
C
:
ChainApi
,
C
hainApi
:
graph
:
:
ChainApi
,
{
/// Adds a new stream of dropped-related events originating in a view with a specific block
/// hash
AddView
(
BlockHash
<
C
>
,
ViewStream
<
C
>
),
AddView
(
BlockHash
<
C
hainApi
>
,
ViewStream
<
C
hainApi
>
),
/// Removes an existing view's stream associated with a specific block hash.
RemoveView
(
BlockHash
<
C
>
),
RemoveView
(
BlockHash
<
C
hainApi
>
),
/// Removes internal states for given extrinsic hashes.
///
/// Intended to ba called on finalization.
RemoveFinalizedTxs
(
Vec
<
ExtrinsicHash
<
C
>>
),
RemoveFinalizedTxs
(
Vec
<
ExtrinsicHash
<
C
hainApi
>>
),
}
impl
<
C
>
Debug
for
Command
<
C
>
impl
<
C
hainApi
>
Debug
for
Command
<
C
hainApi
>
where
C
:
ChainApi
,
C
hainApi
:
graph
:
:
ChainApi
,
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
match
self
{
...
...
@@ -92,29 +92,29 @@ where
///
/// This struct maintains a mapping of active views and their corresponding streams, as well as the
/// state of each transaction with respect to these views.
struct
MultiViewDropWatcherContext
<
C
>
struct
MultiViewDropWatcherContext
<
C
hainApi
>
where
C
:
ChainApi
,
C
hainApi
:
graph
:
:
ChainApi
,
{
/// A map that associates the views identified by corresponding block hashes with their streams
/// of dropped-related events. This map is used to keep track of active views and their event
/// streams.
stream_map
:
StreamMap
<
BlockHash
<
C
>
,
ViewStream
<
C
>>
,
stream_map
:
StreamMap
<
BlockHash
<
C
hainApi
>
,
ViewStream
<
C
hainApi
>>
,
/// A receiver for commands to control the state of the stream, allowing the addition and
/// removal of views. This is used to dynamically update which views are being tracked.
command_receiver
:
CommandReceiver
<
Command
<
C
>>
,
command_receiver
:
CommandReceiver
<
Command
<
C
hainApi
>>
,
/// For each transaction hash we keep the set of hashes representing the views that see this
/// transaction as ready or future.
///
/// Once transaction is dropped, dropping view is removed from the set.
transaction_states
:
HashMap
<
ExtrinsicHash
<
C
>
,
HashSet
<
BlockHash
<
C
>>>
,
transaction_states
:
HashMap
<
ExtrinsicHash
<
C
hainApi
>
,
HashSet
<
BlockHash
<
C
hainApi
>>>
,
}
impl
<
C
>
MultiViewDropWatcherContext
<
C
>
where
C
:
ChainApi
+
'static
,
<<
C
as
ChainApi
>
::
Block
as
BlockT
>
::
Hash
:
Unpin
,
C
:
graph
::
ChainApi
+
'static
,
<<
C
as
graph
::
ChainApi
>
::
Block
as
BlockT
>
::
Hash
:
Unpin
,
{
/// Processes a `ViewStreamEvent` from a specific view and updates the internal state
/// accordingly.
...
...
@@ -220,30 +220,30 @@ where
///
/// This struct provides methods to add and remove streams associated with views to and from the
/// stream.
pub
struct
MultiViewDroppedWatcherController
<
C
:
ChainApi
>
{
pub
struct
MultiViewDroppedWatcherController
<
C
hainApi
:
graph
:
:
ChainApi
>
{
/// A controller allowing to update the state of the associated [`StreamOfDropped`].
controller
:
Controller
<
Command
<
C
>>
,
controller
:
Controller
<
Command
<
C
hainApi
>>
,
}
impl
<
C
:
ChainApi
>
Clone
for
MultiViewDroppedWatcherController
<
C
>
{
impl
<
C
hainApi
:
graph
:
:
ChainApi
>
Clone
for
MultiViewDroppedWatcherController
<
C
hainApi
>
{
fn
clone
(
&
self
)
->
Self
{
Self
{
controller
:
self
.controller
.clone
()
}
}
}
impl
<
C
>
MultiViewDroppedWatcherController
<
C
>
impl
<
C
hainApi
>
MultiViewDroppedWatcherController
<
C
hainApi
>
where
C
:
ChainApi
+
'static
,
<<
C
as
ChainApi
>
::
Block
as
BlockT
>
::
Hash
:
Unpin
,
C
hainApi
:
graph
:
:
ChainApi
+
'static
,
<<
C
hainApi
as
graph
::
ChainApi
>
::
Block
as
BlockT
>
::
Hash
:
Unpin
,
{
/// Creates new [`StreamOfDropped`] and its controller.
pub
fn
new
()
->
(
MultiViewDroppedWatcherController
<
C
>
,
StreamOfDropped
<
C
>
)
{
let
(
stream_map
,
ctrl
)
=
MultiViewDropWatcherContext
::
<
C
>
::
event_stream
();
pub
fn
new
()
->
(
MultiViewDroppedWatcherController
<
C
hainApi
>
,
StreamOfDropped
<
C
hainApi
>
)
{
let
(
stream_map
,
ctrl
)
=
MultiViewDropWatcherContext
::
<
C
hainApi
>
::
event_stream
();
(
Self
{
controller
:
ctrl
},
stream_map
.boxed
())
}
/// Notifies the [`StreamOfDropped`] that new view was created.
pub
fn
add_view
(
&
self
,
key
:
BlockHash
<
C
>
,
view
:
ViewStream
<
C
>
)
{
pub
fn
add_view
(
&
self
,
key
:
BlockHash
<
C
hainApi
>
,
view
:
ViewStream
<
C
hainApi
>
)
{
let
_
=
self
.controller
.unbounded_send
(
Command
::
AddView
(
key
,
view
))
.map_err
(|
e
|
{
trace!
(
target
:
LOG_TARGET
,
"dropped_watcher: add_view {key:?} send message failed: {e}"
);
});
...
...
@@ -251,14 +251,17 @@ where
/// Notifies the [`StreamOfDropped`] that the view was destroyed and shall be removed the
/// stream map.
pub
fn
remove_view
(
&
self
,
key
:
BlockHash
<
C
>
)
{
pub
fn
remove_view
(
&
self
,
key
:
BlockHash
<
C
hainApi
>
)
{
let
_
=
self
.controller
.unbounded_send
(
Command
::
RemoveView
(
key
))
.map_err
(|
e
|
{
trace!
(
target
:
LOG_TARGET
,
"dropped_watcher: remove_view {key:?} send message failed: {e}"
);
});
}
/// Removes status info for finalized transactions.
pub
fn
remove_finalized_txs
(
&
self
,
xts
:
impl
IntoIterator
<
Item
=
ExtrinsicHash
<
C
>>
+
Clone
)
{
pub
fn
remove_finalized_txs
(
&
self
,
xts
:
impl
IntoIterator
<
Item
=
ExtrinsicHash
<
ChainApi
>>
+
Clone
,
)
{
let
_
=
self
.controller
.unbounded_send
(
Command
::
RemoveFinalizedTxs
(
xts
.into_iter
()
.collect
()))
...
...
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