@@ -77,13 +77,31 @@ pub struct BundleProcessor<B, R> {
7777 /// The bundle to process.
7878 pub bundle : B ,
7979 /// The response for the processed bundle.
80- pub response : R ,
80+ response : R ,
8181}
8282
83- impl < B , R > BundleProcessor < B , R > {
83+ impl < B , R > BundleProcessor < B , R >
84+ where
85+ R : Default ,
86+ {
8487 /// Create a new bundle simulator with the given bundle and response.
85- pub const fn new ( bundle : B , response : R ) -> Self {
86- Self { bundle, response }
88+ pub fn new ( bundle : B ) -> Self {
89+ Self { bundle, response : R :: default ( ) }
90+ }
91+
92+ /// Clear the driver, resetting the response. This resets the driver,
93+ /// allowing for resimulation of the same bundle.
94+ pub fn clear ( & mut self ) -> R {
95+ std:: mem:: take ( & mut self . response )
96+ }
97+ }
98+
99+ impl < B , R > From < B > for BundleProcessor < B , R >
100+ where
101+ R : Default ,
102+ {
103+ fn from ( bundle : B ) -> Self {
104+ Self :: new ( bundle)
87105 }
88106}
89107
@@ -109,12 +127,27 @@ impl<B, R> BundleProcessor<B, R> {
109127 Ok ( txs)
110128 }
111129 }
130+
131+ /// Take the response from the bundle driver. This consumes the driver.
132+ pub fn into_response ( self ) -> R {
133+ self . response
134+ }
135+
136+ /// Get a reference to the bundle.
137+ pub const fn bundle ( & self ) -> & B {
138+ & self . bundle
139+ }
140+
141+ /// Get a reference to the response.
142+ pub const fn response ( & self ) -> & R {
143+ & self . response
144+ }
112145}
113146
114147impl BundleProcessor < EthCallBundle , EthCallBundleResponse > {
115148 /// Create a new bundle simulator with the given bundle.
116149 pub fn new_call ( bundle : EthCallBundle ) -> Self {
117- Self :: new ( bundle, EthCallBundleResponse :: default ( ) )
150+ Self :: new ( bundle)
118151 }
119152
120153 /// Process a bundle transaction and accumulate the results into a [EthCallBundleTransactionResult].
0 commit comments