Skip to content

Commit

Permalink
Allow any ExecutionPlatform in BlockPublisher
Browse files Browse the repository at this point in the history
The type of argument to new() should support non-python executors.

Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
  • Loading branch information
Adam Ludvik committed Oct 3, 2018
1 parent e0116d7 commit 3dd270f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 2 additions & 5 deletions validator/src/journal/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use std::thread;
use std::time::Duration;

use execution::execution_platform::ExecutionPlatform;
use execution::py_executor::PyExecutor;
use ffi::py_import_class;
use journal::block_manager::BlockManager;
use journal::candidate_block::{CandidateBlock, CandidateBlockError};
Expand Down Expand Up @@ -505,7 +504,7 @@ impl BlockPublisher {
#![allow(too_many_arguments)]
pub fn new(
block_manager: BlockManager,
transaction_executor: PyObject,
transaction_executor: Box<ExecutionPlatform>,
batch_committed: PyObject,
transaction_committed: PyObject,
state_view_factory: StateViewFactory,
Expand All @@ -519,10 +518,8 @@ impl BlockPublisher {
batch_observers: Vec<PyObject>,
batch_injector_factory: PyObject,
) -> Self {
let tep = Box::new(PyExecutor::new(transaction_executor).unwrap());

let state = Arc::new(RwLock::new(BlockPublisherState::new(
tep,
transaction_executor,
chain_head,
None,
PendingBatchesPool::new(NUM_PUBLISH_COUNT_SAMPLES, INITIAL_PUBLISH_COUNT),
Expand Down
6 changes: 5 additions & 1 deletion validator/src/journal/publisher_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use cpython::{ObjectProtocol, PyClone, PyList, PyObject, Python};

use batch::Batch;
use block::Block;
use execution::py_executor::PyExecutor;
use ffi::py_import_class;
use journal::block_manager::BlockManager;
use journal::publisher::{
Expand Down Expand Up @@ -130,7 +131,10 @@ pub unsafe extern "C" fn block_publisher_new(

let publisher = BlockPublisher::new(
block_manager,
transaction_executor,
Box::new(
PyExecutor::new(transaction_executor)
.expect("Failed to create python transaction executor"),
),
batch_committed,
transaction_committed,
state_view_factory.clone(),
Expand Down

0 comments on commit 3dd270f

Please sign in to comment.