Skip to content

Commit 182d3dd

Browse files
committed
move bundle logic inside
1 parent d5cd9d8 commit 182d3dd

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

crates/ingress-rpc/src/service.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,44 +131,30 @@ where
131131
let start = Instant::now();
132132
let transaction = self.validate_tx(&data).await?;
133133

134-
let expiry_timestamp = SystemTime::now()
135-
.duration_since(UNIX_EPOCH)
136-
.unwrap()
137-
.as_secs()
138-
+ self.send_transaction_default_lifetime_seconds;
139-
140-
let bundle = Bundle {
141-
txs: vec![data.clone()],
142-
max_timestamp: Some(expiry_timestamp),
143-
reverting_tx_hashes: vec![transaction.tx_hash()],
144-
..Default::default()
145-
};
146-
let parsed_bundle: ParsedBundle = bundle
147-
.clone()
148-
.try_into()
149-
.map_err(|e: String| EthApiError::InvalidParams(e).into_rpc_err())?;
134+
match self.tx_submission_method {
135+
TxSubmissionMethod::Kafka => {
136+
let expiry_timestamp = SystemTime::now()
137+
.duration_since(UNIX_EPOCH)
138+
.unwrap()
139+
.as_secs()
140+
+ self.send_transaction_default_lifetime_seconds;
141+
142+
let bundle = Bundle {
143+
txs: vec![data.clone()],
144+
max_timestamp: Some(expiry_timestamp),
145+
reverting_tx_hashes: vec![transaction.tx_hash()],
146+
..Default::default()
147+
};
148+
let parsed_bundle: ParsedBundle = bundle
149+
.clone()
150+
.try_into()
151+
.map_err(|e: String| EthApiError::InvalidParams(e).into_rpc_err())?;
150152

151-
let bundle_hash = &parsed_bundle.bundle_hash();
152-
let meter_bundle_response = self.meter_bundle(&bundle, bundle_hash).await?;
153+
let bundle_hash = &parsed_bundle.bundle_hash();
154+
let meter_bundle_response = self.meter_bundle(&bundle, bundle_hash).await?;
153155

154-
let accepted_bundle = AcceptedBundle::new(parsed_bundle, meter_bundle_response);
156+
let accepted_bundle = AcceptedBundle::new(parsed_bundle, meter_bundle_response);
155157

156-
match self.tx_submission_method {
157-
TxSubmissionMethod::Mempool => {
158-
let response = self
159-
.provider
160-
.send_raw_transaction(data.iter().as_slice())
161-
.await;
162-
match response {
163-
Ok(_) => {
164-
info!(message = "sent transaction to the mempool", hash=%transaction.tx_hash());
165-
}
166-
Err(e) => {
167-
warn!(message = "Failed to send raw transaction to mempool", error = %e);
168-
}
169-
}
170-
}
171-
TxSubmissionMethod::Kafka => {
172158
if let Err(e) = self
173159
.bundle_queue
174160
.publish(&accepted_bundle, bundle_hash)
@@ -187,6 +173,20 @@ where
187173
warn!(message = "Failed to send audit event", error = %e);
188174
}
189175
}
176+
TxSubmissionMethod::Mempool => {
177+
let response = self
178+
.provider
179+
.send_raw_transaction(data.iter().as_slice())
180+
.await;
181+
match response {
182+
Ok(_) => {
183+
info!(message = "sent transaction to the mempool", hash=%transaction.tx_hash());
184+
}
185+
Err(e) => {
186+
warn!(message = "Failed to send raw transaction to mempool", error = %e);
187+
}
188+
}
189+
}
190190
}
191191

192192
self.metrics

0 commit comments

Comments
 (0)