3434/// This trait defines a set of transactions that are bundled together and
3535/// should be processed as a single unit of execution.
3636///
37- /// Examples of bundles are objects sent through the `eth_sendBundle` RPC
38- /// method.
37+ /// Examples of bundles are objects sent through the [`eth_sendBundle`] JSON-RPC
38+ /// endpoint.
39+ ///
40+ /// [`eth_sendBundle`]: https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint#eth_sendbundle
3941pub trait Bundle < P : Platform > :
4042 Serialize + DeserializeOwned + Clone + Debug + Send + Sync + ' static
4143{
@@ -49,8 +51,8 @@ pub trait Bundle<P: Platform>:
4951 /// maintain the same order of transactions as the original bundle.
5052 ///
5153 /// The system guarantees that this function will not be called for a
52- /// transaction that is not in the bundle, or a transaction that is not
53- /// optional or the last remaining transaction in the bundle.
54+ /// transaction not in the bundle, not optional or not the last remaining in
55+ /// the bundle.
5456 #[ must_use]
5557 fn without_transaction ( self , tx : TxHash ) -> Self ;
5658
@@ -62,7 +64,7 @@ pub trait Bundle<P: Platform>:
6264 /// it will never be eligible for inclusion in any future block that is a
6365 /// descendant of the given header.
6466 ///
65- /// Implementing this method is optional for bundles but it gives the ability
67+ /// Implementing this method is optional for bundles, but it gives the ability
6668 /// to filter out bundles at the RPC level before they are sent to the pool.
6769 fn is_permanently_ineligible (
6870 & self ,
@@ -71,23 +73,24 @@ pub trait Bundle<P: Platform>:
7173 false
7274 }
7375
74- /// Checks if a transaction with a given hash is allowed to not have a
76+ /// Checks if a transaction of the given hash is allowed to not have a
7577 /// successful execution result for this bundle.
7678 ///
77- /// the `tx` is the hash of the transaction to check and it is guaranteed to
78- /// be hash of one of the transactions returned by `transactions()` .
79+ /// The `tx` is the hash of the transaction to check, that should be part of
80+ /// this bundle .
7981 fn is_allowed_to_fail ( & self , tx : TxHash ) -> bool ;
8082
8183 /// Checks if a transaction with the given hash may be removed from the
8284 /// bundle without affecting its validity.
8385 fn is_optional ( & self , tx : TxHash ) -> bool ;
8486
8587 /// An optional check for bundle implementations that have validity
86- /// requirements on the resulting state. For example there may be an
87- /// implementation that requires a certain minimal balance in some account
88- /// after the bundle is executed. The state that is passed in this method
89- /// contains only entries that were modified or created by executing
90- /// transactions from this bundle.
88+ /// requirements on the resulting state.
89+ ///
90+ /// For example, an implementation can require a minimal balance for some
91+ /// accounts after bundle execution. The state passed in this method contains
92+ /// only entries that were modified or created by executing transactions from
93+ /// this bundle.
9194 fn validate_post_execution (
9295 & self ,
9396 _: & BundleState ,
@@ -111,7 +114,7 @@ pub enum Eligibility {
111114 /// mean that the bundle will actually be included, but only that static
112115 /// checks that do not require execution checks have passed.
113116 ///
114- /// Bundles in this state if not included in the block should be kept in the
117+ /// Bundles in this state, if not included in the block, should be kept in the
115118 /// pool and retried in future blocks.
116119 Eligible ,
117120
@@ -130,7 +133,7 @@ pub enum Eligibility {
130133 /// implementation supports this type of limit.
131134 ///
132135 /// Bundles in this state should be removed from the pool and not attempted
133- /// to be included in any future blocks.
136+ /// for inclusion in any future blocks.
134137 ///
135138 /// Once a bundle returns this state, it should never return any other
136139 /// eligibility state.
@@ -141,21 +144,13 @@ impl Eligibility {
141144 /// Returns `Some(f())` if the eligibility is `Eligible`, otherwise returns
142145 /// `None`.
143146 pub fn then < T , F : FnOnce ( ) -> T > ( self , f : F ) -> Option < T > {
144- if self == Eligibility :: Eligible {
145- Some ( f ( ) )
146- } else {
147- None
148- }
147+ matches ! ( self , Eligibility :: Eligible ) . then ( f)
149148 }
150149
151150 /// Returns `Some(t)` if the eligibility is `Eligible`, otherwise returns
152151 /// `None`.
153152 pub fn then_some < T > ( self , t : T ) -> Option < T > {
154- if self == Eligibility :: Eligible {
155- Some ( t)
156- } else {
157- None
158- }
153+ matches ! ( self , Eligibility :: Eligible ) . then_some ( t)
159154 }
160155}
161156
@@ -179,11 +174,11 @@ impl Not for Eligibility {
179174 }
180175}
181176
182- /// A bundle of transactions that adheres to the [Flashbots specification].
183- /// see: <https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint#eth_sendbundle>
177+ /// A [Bundle] that follows Flashbots [`eth_sendBundle`] specification.
178+ ///
179+ /// Default bundle type used by both `Ethereum` and `Optimism` platforms.
184180///
185- /// By default this is the bundle type that is used by both the `Ethereum` and
186- /// `Optimism` platforms.
181+ /// [`eth_sendBundle`]: https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint#eth_sendbundle
187182#[ derive( Debug , Clone ) ]
188183pub struct FlashbotsBundle < P : Platform > {
189184 inner : EthSendBundle ,
0 commit comments