Skip to content

Commit aa222d2

Browse files
author
Solar Mithril
committed
Change faulty logic
1 parent 0987f62 commit aa222d2

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

crates/op-rbuilder/src/generator.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ pub trait PayloadBuilder: Send + Sync + Clone {
5151
&self,
5252
args: BuildArguments<Self::Attributes, Self::BuiltPayload>,
5353
best_payload: BlockCell<Self::BuiltPayload>,
54-
) -> Result<(), PayloadBuilderError>;
54+
tx: Sender<Result<(), PayloadBuilderError>>,
55+
);
5556
}
5657

5758
/// The generator type that creates new jobs that builds empty blocks.
@@ -174,6 +175,7 @@ use std::{
174175
pin::Pin,
175176
task::{Context, Poll},
176177
};
178+
use tokio::sync::oneshot::Sender;
177179

178180
/// A [PayloadJob] that builds empty blocks.
179181
pub struct BlockPayloadJob<Builder>
@@ -256,8 +258,7 @@ where
256258
cancel,
257259
};
258260

259-
let result = builder.try_build(args, cell);
260-
let _ = tx.send(result);
261+
builder.try_build(args, cell, tx);
261262
}
262263
}
263264

@@ -545,13 +546,15 @@ mod tests {
545546
&self,
546547
args: BuildArguments<Self::Attributes, Self::BuiltPayload>,
547548
_best_payload: BlockCell<Self::BuiltPayload>,
548-
) -> Result<(), PayloadBuilderError> {
549+
tx: Sender<Result<(), PayloadBuilderError>>,
550+
) {
549551
self.new_event(BlockEvent::Started);
550552

551553
loop {
552554
if args.cancel.is_cancelled() {
553555
self.new_event(BlockEvent::Cancelled);
554-
return Ok(());
556+
let _ = tx.send(Ok(()));
557+
return;
555558
}
556559

557560
// Small sleep to prevent tight loop

crates/op-rbuilder/src/payload_builder_vanilla.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use revm::{
7575
use std::error::Error as StdError;
7676
use std::{fmt::Display, sync::Arc, time::Instant};
7777
use tokio::sync::oneshot;
78+
use tokio::sync::oneshot::Sender;
7879
use tokio_util::sync::CancellationToken;
7980
use tracing::{info, trace, warn};
8081

@@ -274,10 +275,10 @@ where
274275
&self,
275276
args: BuildArguments<Self::Attributes, Self::BuiltPayload>,
276277
best_payload: BlockCell<Self::BuiltPayload>,
277-
) -> Result<(), PayloadBuilderError> {
278+
tx: Sender<Result<(), PayloadBuilderError>>,
279+
) {
278280
let pool = self.pool.clone();
279281
let block_build_start_time = Instant::now();
280-
let (tx, rx) = oneshot::channel();
281282
let ctx = self.clone();
282283
self.executor.spawn_blocking(Box::pin(async move {
283284
match ctx.build_payload(args, |attrs| {
@@ -313,7 +314,6 @@ where
313314
}
314315
}
315316
}));
316-
rx.blocking_recv().map_err(PayloadBuilderError::from)?
317317
}
318318
}
319319

0 commit comments

Comments
 (0)