Skip to content

Commit 49682b0

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

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ use revm::{
7474
};
7575
use std::error::Error as StdError;
7676
use std::{fmt::Display, sync::Arc, time::Instant};
77-
use tokio::sync::oneshot;
77+
use tokio::sync::oneshot::Sender;
7878
use tokio_util::sync::CancellationToken;
7979
use tracing::{info, trace, warn};
8080

@@ -274,10 +274,10 @@ where
274274
&self,
275275
args: BuildArguments<Self::Attributes, Self::BuiltPayload>,
276276
best_payload: BlockCell<Self::BuiltPayload>,
277-
) -> Result<(), PayloadBuilderError> {
277+
tx: Sender<Result<(), PayloadBuilderError>>,
278+
) {
278279
let pool = self.pool.clone();
279280
let block_build_start_time = Instant::now();
280-
let (tx, rx) = oneshot::channel();
281281
let ctx = self.clone();
282282
self.executor.spawn_blocking(Box::pin(async move {
283283
match ctx.build_payload(args, |attrs| {
@@ -313,7 +313,6 @@ where
313313
}
314314
}
315315
}));
316-
rx.blocking_recv().map_err(PayloadBuilderError::from)?
317316
}
318317
}
319318

0 commit comments

Comments
 (0)