def __init__(self, transaction_executor, block_cache, state_view_factory, block_sender, batch_sender, squash_handler, chain_head, identity_signing_key, data_dir, config_dir, permission_verifier, batch_injector_factory=None): """ Initialize the BlockPublisher object Args: transaction_executor (:obj:`TransactionExecutor`): A TransactionExecutor instance. block_cache (:obj:`BlockCache`): A BlockCache instance. state_view_factory (:obj:`StateViewFactory`): StateViewFactory for read-only state views. block_sender (:obj:`BlockSender`): The BlockSender instance. batch_sender (:obj:`BatchSender`): The BatchSender instance. squash_handler (function): Squash handler function for merging contexts. chain_head (:obj:`BlockWrapper`): The initial chain head. identity_signing_key (str): Private key for signing blocks data_dir (str): path to location where persistent data for the consensus module can be stored. config_dir (str): path to location where configuration can be found. batch_injector_factory (:obj:`BatchInjectorFatctory`): A factory for creating BatchInjectors.""" self._lock = RLock() self._candidate_block = None # _CandidateBlock helper, # the next block in potential chain self._block_cache = block_cache self._state_view_factory = state_view_factory self._transaction_executor = transaction_executor self._block_sender = block_sender self._batch_publisher = BatchPublisher(identity_signing_key, batch_sender) self._pending_batches = [] # batches we are waiting for validation, # arranged in the order of batches received. self._chain_head = chain_head # block (BlockWrapper) self._squash_handler = squash_handler self._identity_signing_key = identity_signing_key self._identity_public_key = \ signing.generate_pubkey(self._identity_signing_key) self._data_dir = data_dir self._config_dir = config_dir self._permission_verifier = permission_verifier self._batch_injector_factory = batch_injector_factory
def __init__(self, transaction_executor, block_cache, state_view_factory, block_sender, batch_sender, squash_handler, chain_head, identity_signing_key, data_dir): """ Initialize the BlockPublisher object Args: transaction_executor (:obj:`TransactionExecutor`): A TransactionExecutor instance. block_cache (:obj:`BlockCache`): A BlockCache instance. state_view_factory (:obj:`StateViewFactory`): StateViewFactory for read-only state views. block_sender (:obj:`BlockSender`): The BlockSender instance. batch_sender (:obj:`BatchSender`): The BatchSender instance. squash_handler (function): Squash handler function for merging contexts. chain_head (:obj:`BlockWrapper`): The initial chain head. identity_signing_key (str): Private key for signing blocks """ self._lock = RLock() self._candidate_block = None # the next block in potentia self._consensus = None self._block_cache = block_cache self._state_view_factory = state_view_factory self._transaction_executor = transaction_executor self._block_sender = block_sender self._batch_publisher = BatchPublisher(identity_signing_key, batch_sender) self._pending_batches = [] # batches we are waiting for validation, # arranged in the order of batches received. self._committed_txn_cache = TransactionCache(self._block_cache. block_store) # Look-up cache for transactions that are committed in the current # chain. Cache is used here so that we can support opportunistically # building on top of a block we published. As well as hold the state # of the transactions already added to the candidate block. self._scheduler = None self._chain_head = chain_head # block (BlockWrapper) self._squash_handler = squash_handler self._identity_signing_key = identity_signing_key self._identity_public_key = \ signing.generate_pubkey(self._identity_signing_key) self._data_dir = data_dir
def __init__(self, transaction_executor, block_cache, state_view_factory, block_sender, batch_sender, squash_handler, chain_head, identity_signer, data_dir, config_dir, permission_verifier, check_publish_block_frequency, batch_observers, batch_injector_factory=None, metrics_registry=None): """ Initialize the BlockPublisher object Args: transaction_executor (:obj:`TransactionExecutor`): A TransactionExecutor instance. block_cache (:obj:`BlockCache`): A BlockCache instance. state_view_factory (:obj:`StateViewFactory`): StateViewFactory for read-only state views. block_sender (:obj:`BlockSender`): The BlockSender instance. batch_sender (:obj:`BatchSender`): The BatchSender instance. squash_handler (function): Squash handler function for merging contexts. chain_head (:obj:`BlockWrapper`): The initial chain head. identity_signer (:obj:`Signer`): Cryptographic signer for signing blocks data_dir (str): path to location where persistent data for the consensus module can be stored. config_dir (str): path to location where configuration can be found. batch_injector_factory (:obj:`BatchInjectorFatctory`): A factory for creating BatchInjectors. metrics_registry (MetricsRegistry): Metrics registry used to create pending batch gauge """ self._lock = RLock() self._candidate_block = None # _CandidateBlock helper, # the next block in potential chain self._block_cache = block_cache self._state_view_factory = state_view_factory self._transaction_executor = transaction_executor self._block_sender = block_sender self._batch_publisher = BatchPublisher(identity_signer, batch_sender) self._pending_batches = [] # batches we are waiting for validation, # arranged in the order of batches received. self._pending_batch_ids = [] self._chain_head = chain_head # block (BlockWrapper) self._squash_handler = squash_handler self._identity_signer = identity_signer self._data_dir = data_dir self._config_dir = config_dir self._permission_verifier = permission_verifier self._batch_injector_factory = batch_injector_factory # For metric gathering self._pending_batch_gauge = \ metrics_registry.gauge('pending_batch_gauge') \ if metrics_registry else None self._batch_queue = queue.Queue() self._queued_batch_ids = [] self._batch_observers = batch_observers self._check_publish_block_frequency = check_publish_block_frequency self._publisher_thread = None
def __init__(self, transaction_executor, block_cache, state_view_factory, settings_cache, block_sender, batch_sender, chain_head, identity_signer, data_dir, config_dir, permission_verifier, check_publish_block_frequency, batch_observers, batch_injector_factory=None): """ Initialize the BlockPublisher object Args: transaction_executor (:obj:`TransactionExecutor`): A TransactionExecutor instance. block_cache (:obj:`BlockCache`): A BlockCache instance. state_view_factory (:obj:`StateViewFactory`): StateViewFactory for read-only state views. block_sender (:obj:`BlockSender`): The BlockSender instance. batch_sender (:obj:`BatchSender`): The BatchSender instance. chain_head (:obj:`BlockWrapper`): The initial chain head. identity_signer (:obj:`Signer`): Cryptographic signer for signing blocks data_dir (str): path to location where persistent data for the consensus module can be stored. config_dir (str): path to location where configuration can be found. batch_injector_factory (:obj:`BatchInjectorFatctory`): A factory for creating BatchInjectors. """ self._lock = RLock() self._candidate_block = None # _CandidateBlock helper, # the next block in potential chain self._block_cache = block_cache self._state_view_factory = state_view_factory self._settings_cache = settings_cache self._transaction_executor = transaction_executor self._block_sender = block_sender self._batch_publisher = BatchPublisher(identity_signer, batch_sender) self._pending_batches = PendingBatchesPool(NUM_PUBLISH_COUNT_SAMPLES, INITIAL_PUBLISH_COUNT) self._chain_head = chain_head # block (BlockWrapper) self._identity_signer = identity_signer self._data_dir = data_dir self._config_dir = config_dir self._permission_verifier = permission_verifier self._batch_injector_factory = batch_injector_factory # For metric gathering self._blocks_published_count = COLLECTOR.counter( 'blocks_published_count', instance=self) self._batch_queue = IncomingBatchQueue() self._batch_observers = batch_observers self._check_publish_block_frequency = check_publish_block_frequency self._publisher_thread = None # A series of states that allow us to check for condition changes. # These can be used to log only at the boundary of condition changes. self._logging_states = _PublisherLoggingStates()