def test_batch_handler_commit(batch_handler: BatchRequestHandler,
                              three_pc_batch):
    assert len(batch_handler.ledger) == 0

    batch_handler.commit_batch(three_pc_batch)

    assert len(batch_handler.ledger) == 1

    batch_handler._check_consistency_after_commit(FIXED_HASH)
Exemple #2
0
    def __init__(self, database_manager: DatabaseManager):
        BatchRequestHandler.__init__(self, database_manager, POOL_LEDGER_ID)
        WriteRequestHandler.__init__(self, database_manager, NODE,
                                     POOL_LEDGER_ID)

        self.uncommitted_node_reg = []
        self.committed_node_reg = []
        self.node_reg_at_beginning_of_view = SortedDict()

        self._uncommitted = deque()  # type: deque[UncommittedNodeReg]
        self._committed_view_no = 0
    def __init__(self, database_manager: DatabaseManager):
        BatchRequestHandler.__init__(self, database_manager, POOL_LEDGER_ID)
        WriteRequestHandler.__init__(self, database_manager, NODE,
                                     POOL_LEDGER_ID)

        self.uncommitted_node_reg = []
        self.committed_node_reg = []

        # committed node reg at the beginning of view
        # matches the committed node reg BEFORE the first txn in a view is applied (that is according to the last txn in the last view)
        self.committed_node_reg_at_beginning_of_view = SortedDict()

        # uncommitted node reg at the beginning of view
        # matches the uncommittednode reg BEFORE the first txn in a view is applied (that is according to the last txn in the last view)
        self.uncommitted_node_reg_at_beginning_of_view = SortedDict()

        self._uncommitted = deque()  # type: deque[UncommittedNodeReg]
        self._uncommitted_view_no = 0
        self._committed_view_no = 0

        self.internal_bus = None  # type: InternalBus
Exemple #4
0
 def __init__(self, database_manager: DatabaseManager,
              node_reg_handler: NodeRegHandler):
     BatchRequestHandler.__init__(self, database_manager, POOL_LEDGER_ID)
     self.primaries_selector = RoundRobinNodeRegPrimariesSelector(
         node_reg_handler)
def batch_handler(database_manager):
    bh = BatchRequestHandler(database_manager, LEDGER_ID)
    bh.ledger.appendTxns([{'txnMetadata': {'seqNo': 1}}])
    return bh