@@ -22,28 +22,36 @@ pub struct TransactionStatusResponse {
2222/// Extended subscription kind that includes both standard Ethereum subscription types
2323/// and flashblocks-specific types.
2424///
25- /// This enum wraps the standard `SubscriptionKind` from alloy and adds flashblocks support,
26- /// allowing `eth_subscribe` to handle both standard subscriptions (newHeads, logs, etc.)
25+ /// This enum encapsulates the standard [ `SubscriptionKind`] from alloy and adds flashblocks
26+ /// support, allowing `eth_subscribe` to handle both standard subscriptions (newHeads, logs, etc.)
2727/// and custom flashblocks subscriptions.
28+ ///
29+ /// By encapsulating [`SubscriptionKind`] rather than redefining its variants, we automatically
30+ /// inherit support for any new variants added upstream, or get a compile error if the signature
31+ /// changes.
2832#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
29- #[ serde( rename_all = "camelCase" ) ]
33+ #[ serde( untagged ) ]
3034pub enum ExtendedSubscriptionKind {
31- /// New block headers subscription (standard).
32- NewHeads ,
33- /// Logs subscription (standard).
34- Logs ,
35- /// New pending transactions subscription (standard).
36- NewPendingTransactions ,
37- /// Node syncing status subscription (standard).
38- Syncing ,
39- /// New flashblocks subscription (Base-specific).
35+ /// Standard Ethereum subscription types (newHeads, logs, newPendingTransactions, syncing).
36+ ///
37+ /// These are proxied to reth's underlying `EthPubSub` implementation.
38+ Standard ( SubscriptionKind ) ,
39+ /// Base-specific subscription types for flashblocks.
40+ Base ( BaseSubscriptionKind ) ,
41+ }
42+
43+ /// Base-specific subscription types for flashblocks.
44+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
45+ #[ serde( rename_all = "camelCase" ) ]
46+ pub enum BaseSubscriptionKind {
47+ /// New flashblocks subscription.
4048 ///
4149 /// Fires a notification each time a new flashblock is processed, providing the current
4250 /// pending block state. Each flashblock represents an incremental update to the pending
4351 /// block, so multiple notifications may be emitted for the same block height as new
4452 /// flashblocks arrive.
4553 NewFlashblocks ,
46- /// Pending logs subscription (Base-specific) .
54+ /// Pending logs subscription.
4755 ///
4856 /// Returns logs from flashblocks pending state that match the given filter criteria.
4957 /// Unlike standard `logs` subscription which only includes logs from confirmed blocks,
@@ -55,16 +63,25 @@ impl ExtendedSubscriptionKind {
5563 /// Returns the standard subscription kind if this is a standard subscription type.
5664 pub const fn as_standard ( & self ) -> Option < SubscriptionKind > {
5765 match self {
58- Self :: NewHeads => Some ( SubscriptionKind :: NewHeads ) ,
59- Self :: Logs => Some ( SubscriptionKind :: Logs ) ,
60- Self :: NewPendingTransactions => Some ( SubscriptionKind :: NewPendingTransactions ) ,
61- Self :: Syncing => Some ( SubscriptionKind :: Syncing ) ,
62- Self :: NewFlashblocks | Self :: PendingLogs => None ,
66+ Self :: Standard ( kind) => Some ( * kind) ,
67+ Self :: Base ( _) => None ,
6368 }
6469 }
6570
6671 /// Returns true if this is a flashblocks-specific subscription.
6772 pub const fn is_flashblocks ( & self ) -> bool {
68- matches ! ( self , Self :: NewFlashblocks | Self :: PendingLogs )
73+ matches ! ( self , Self :: Base ( _) )
74+ }
75+ }
76+
77+ impl From < SubscriptionKind > for ExtendedSubscriptionKind {
78+ fn from ( kind : SubscriptionKind ) -> Self {
79+ Self :: Standard ( kind)
80+ }
81+ }
82+
83+ impl From < BaseSubscriptionKind > for ExtendedSubscriptionKind {
84+ fn from ( kind : BaseSubscriptionKind ) -> Self {
85+ Self :: Base ( kind)
6986 }
7087}
0 commit comments