Skip to content

Commit

Permalink
Drop unused blockstore references
Browse files Browse the repository at this point in the history
These are not used.

Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
  • Loading branch information
Adam Ludvik committed Oct 1, 2018
1 parent 0173e37 commit e97b3c7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 188 deletions.
2 changes: 0 additions & 2 deletions validator/sawtooth_validator/journal/block_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def __init__(self,
transaction_executor,
block_status_store,
permission_verifier,
block_store,
view_factory):
super(BlockValidator, self).__init__("block_validator_drop")

Expand All @@ -36,7 +35,6 @@ def __init__(self,
ctypes.py_object(transaction_executor),
block_status_store.pointer,
ctypes.py_object(permission_verifier),
ctypes.py_object(block_store),
view_factory.pointer,
ctypes.byref(self.pointer)))

Expand Down
1 change: 0 additions & 1 deletion validator/sawtooth_validator/server/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ def __init__(self,

block_validator = BlockValidator(
block_manager=block_manager,
block_store=block_store,
view_factory=native_state_view_factory,
transaction_executor=transaction_executor,
block_status_store=block_status_store,
Expand Down
43 changes: 5 additions & 38 deletions validator/src/journal/block_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ use block::Block;
use execution::execution_platform::{ExecutionPlatform, NULL_STATE_HASH};
use gossip::permission_verifier::PermissionVerifier;
use journal::block_scheduler::BlockScheduler;
use journal::block_store::{BatchIndex, TransactionIndex};
use journal::chain_commit_state::{
validate_no_duplicate_batches, validate_no_duplicate_transactions,
validate_transaction_dependencies, ChainCommitStateError,
};
use journal::validation_rule_enforcer::enforce_validation_rules;
use journal::{block_manager::BlockManager, block_store::BlockStore, block_wrapper::BlockStatus};
use journal::{block_manager::BlockManager, block_wrapper::BlockStatus};
use scheduler::TxnExecutionResult;
use state::{settings_view::SettingsView, state_view_factory::StateViewFactory};
use std::sync::{
Expand Down Expand Up @@ -163,50 +162,29 @@ impl BlockValidationResult {
type InternalSender = Sender<(Block, Sender<BlockValidationResult>)>;
type InternalReceiver = Receiver<(Block, Sender<BlockValidationResult>)>;

pub struct BlockValidator<
TEP: ExecutionPlatform,
PV: PermissionVerifier,
BS: BlockStore,
B: BatchIndex,
T: TransactionIndex,
> {
pub struct BlockValidator<TEP: ExecutionPlatform, PV: PermissionVerifier> {
channels: Vec<(InternalSender, Option<InternalReceiver>)>,
index: Arc<AtomicUsize>,
validation_thread_exit: Arc<AtomicBool>,
block_scheduler: BlockScheduler<BlockValidationResultStore>,
block_status_store: BlockValidationResultStore,
block_manager: BlockManager,
block_store: BS,
batch_index: B,
transaction_executor: TEP,
transaction_index: T,
view_factory: StateViewFactory,
permission_verifier: PV,
}

impl<
TEP: ExecutionPlatform + 'static,
PV: PermissionVerifier + 'static,
BS: BlockStore + 'static,
B: BatchIndex + 'static,
T: TransactionIndex + 'static,
> BlockValidator<TEP, PV, BS, B, T>
impl<TEP: ExecutionPlatform + 'static, PV: PermissionVerifier + 'static> BlockValidator<TEP, PV>
where
TEP: Clone,
PV: Clone,
BS: Clone,
B: Clone,
T: Clone,
{
#[allow(too_many_arguments)]
pub fn new(
block_manager: BlockManager,
transaction_executor: TEP,
block_status_store: BlockValidationResultStore,
permission_verifier: PV,
block_store: BS,
batch_index: B,
transaction_index: T,
view_factory: StateViewFactory,
) -> Self {
let mut channels = vec![];
Expand All @@ -222,9 +200,6 @@ where
block_scheduler: BlockScheduler::new(block_manager.clone(), block_status_store.clone()),
block_status_store,
block_manager,
block_store,
batch_index,
transaction_index,
view_factory,
permission_verifier,
}
Expand Down Expand Up @@ -399,13 +374,8 @@ where
}
}

impl<
TEP: ExecutionPlatform + Clone,
PV: PermissionVerifier + Clone,
BS: BlockStore + Clone,
B: BatchIndex + Clone,
T: TransactionIndex + Clone,
> Clone for BlockValidator<TEP, PV, BS, B, T>
impl<TEP: ExecutionPlatform + Clone, PV: PermissionVerifier + Clone> Clone
for BlockValidator<TEP, PV>
{
fn clone(&self) -> Self {
let transaction_executor = self.transaction_executor.clone();
Expand All @@ -426,9 +396,6 @@ impl<
block_scheduler: self.block_scheduler.clone(),
block_status_store: self.block_status_store.clone(),
block_manager: self.block_manager.clone(),
block_store: self.block_store.clone(),
batch_index: self.batch_index.clone(),
transaction_index: self.transaction_index.clone(),
permission_verifier: self.permission_verifier.clone(),
view_factory: self.view_factory.clone(),
}
Expand Down
42 changes: 3 additions & 39 deletions validator/src/journal/block_validator_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use cpython;
use execution::py_executor::PyExecutor;
use gossip::permission_verifier::PyPermissionVerifier;
use journal::chain_ffi::PyBlockStore;
use journal::{
block_manager::BlockManager,
block_validator::{BlockValidationResultStore, BlockValidator},
Expand Down Expand Up @@ -66,7 +65,6 @@ pub unsafe extern "C" fn block_validator_new(
transaction_executor_ptr: *mut py_ffi::PyObject,
block_status_store_ptr: *const c_void,
permission_verifier: *mut py_ffi::PyObject,
block_store: *mut py_ffi::PyObject,
view_factory_ptr: *const c_void,
block_validator_ptr: *mut *const c_void,
) -> ErrorCode {
Expand All @@ -85,12 +83,6 @@ pub unsafe extern "C" fn block_validator_new(
let py_transaction_executor =
PyExecutor::new(ex).expect("The PyExecutor could not be created from a PyObject");

let py_block_store = PyBlockStore::new(cpython::PyObject::from_borrowed_ptr(py, block_store));

let block_store = py_block_store.clone();
let batch_index = py_block_store.clone();
let transaction_index: PyBlockStore = py_block_store.clone();

let py_permission_verifier: PyPermissionVerifier = PyPermissionVerifier::new(
cpython::PyObject::from_borrowed_ptr(py, permission_verifier),
);
Expand All @@ -100,9 +92,6 @@ pub unsafe extern "C" fn block_validator_new(
py_transaction_executor,
block_status_store,
py_permission_verifier,
block_store,
batch_index,
transaction_index,
view_factory,
);

Expand All @@ -115,31 +104,15 @@ pub unsafe extern "C" fn block_validator_new(
pub unsafe extern "C" fn block_validator_start(block_validator_ptr: *mut c_void) -> ErrorCode {
check_null!(block_validator_ptr);

(*(block_validator_ptr
as *mut BlockValidator<
PyExecutor,
PyPermissionVerifier,
PyBlockStore,
PyBlockStore,
PyBlockStore,
>))
.start();
(*(block_validator_ptr as *mut BlockValidator<PyExecutor, PyPermissionVerifier>)).start();

ErrorCode::Success
}

#[no_mangle]
pub unsafe extern "C" fn block_validator_stop(block_validator_ptr: *mut c_void) -> ErrorCode {
check_null!(block_validator_ptr);
(*(block_validator_ptr
as *mut BlockValidator<
PyExecutor,
PyPermissionVerifier,
PyBlockStore,
PyBlockStore,
PyBlockStore,
>))
.stop();
(*(block_validator_ptr as *mut BlockValidator<PyExecutor, PyPermissionVerifier>)).stop();

ErrorCode::Success
}
Expand All @@ -148,16 +121,7 @@ pub unsafe extern "C" fn block_validator_stop(block_validator_ptr: *mut c_void)
pub unsafe extern "C" fn block_validator_drop(block_validator_ptr: *mut c_void) -> ErrorCode {
check_null!(block_validator_ptr);

Box::from_raw(
block_validator_ptr
as *mut BlockValidator<
PyExecutor,
PyPermissionVerifier,
PyBlockStore,
PyBlockStore,
PyBlockStore,
>,
);
Box::from_raw(block_validator_ptr as *mut BlockValidator<PyExecutor, PyPermissionVerifier>);

ErrorCode::Success
}
43 changes: 10 additions & 33 deletions validator/src/journal/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use execution::execution_platform::ExecutionPlatform;
use gossip::permission_verifier::PermissionVerifier;
use journal;
use journal::block_manager::{BlockManager, BlockManagerError};
use journal::block_store::{BatchIndex, BlockStore, TransactionIndex};
use journal::block_validator::{
BlockValidationResult, BlockValidationResultStore, BlockValidator, ValidationError,
};
Expand Down Expand Up @@ -246,18 +245,12 @@ impl ChainControllerState {
}

#[derive(Clone)]
pub struct ChainController<
TEP: ExecutionPlatform + Clone,
PV: PermissionVerifier + Clone,
BS: BlockStore + Clone,
B: BatchIndex + Clone,
T: TransactionIndex + Clone,
> {
pub struct ChainController<TEP: ExecutionPlatform + Clone, PV: PermissionVerifier + Clone> {
state: Arc<RwLock<ChainControllerState>>,
stop_handle: Arc<Mutex<Option<ChainThreadStopHandle>>>,

consensus_notifier: Arc<ConsensusNotifier>,
block_validator: BlockValidator<TEP, PV, BS, B, T>,
block_validator: BlockValidator<TEP, PV>,
block_validation_results: BlockValidationResultStore,

// Queues
Expand All @@ -269,18 +262,13 @@ pub struct ChainController<
chain_head_lock: ChainHeadLock,
}

impl<
TEP: ExecutionPlatform + Clone + 'static,
PV: PermissionVerifier + Clone + 'static,
BS: BlockStore + Clone + 'static,
B: BatchIndex + Clone + 'static,
T: TransactionIndex + Clone + 'static,
> ChainController<TEP, PV, BS, B, T>
impl<TEP: ExecutionPlatform + Clone + 'static, PV: PermissionVerifier + Clone + 'static>
ChainController<TEP, PV>
{
#![allow(too_many_arguments)]
pub fn new(
block_manager: BlockManager,
block_validator: BlockValidator<TEP, PV, BS, B, T>,
block_validator: BlockValidator<TEP, PV>,
chain_reader: Box<ChainReader>,
chain_head_lock: ChainHeadLock,
block_validation_results: BlockValidationResultStore,
Expand Down Expand Up @@ -1055,14 +1043,8 @@ impl<'a> From<&'a TxnExecutionResult> for TransactionReceipt {
}
}

struct ChainThread<
TEP: ExecutionPlatform + Clone,
PV: PermissionVerifier + Clone,
BS: BlockStore + Clone,
B: BatchIndex + Clone,
T: TransactionIndex + Clone,
> {
chain_controller: ChainController<TEP, PV, BS, B, T>,
struct ChainThread<TEP: ExecutionPlatform + Clone, PV: PermissionVerifier + Clone> {
chain_controller: ChainController<TEP, PV>,
block_queue: Receiver<String>,
exit: Arc<AtomicBool>,
}
Expand All @@ -1071,16 +1053,11 @@ trait StopHandle: Clone {
fn stop(&self);
}

impl<
TEP: ExecutionPlatform + Clone + 'static,
PV: PermissionVerifier + Clone + 'static,
BS: BlockStore + Clone + 'static,
B: BatchIndex + Clone + 'static,
T: TransactionIndex + Clone + 'static,
> ChainThread<TEP, PV, BS, B, T>
impl<TEP: ExecutionPlatform + Clone + 'static, PV: PermissionVerifier + Clone + 'static>
ChainThread<TEP, PV>
{
fn new(
chain_controller: ChainController<TEP, PV, BS, B, T>,
chain_controller: ChainController<TEP, PV>,
block_queue: Receiver<String>,
exit_flag: Arc<AtomicBool>,
) -> Self {
Expand Down
Loading

0 comments on commit e97b3c7

Please sign in to comment.