Exemplo n.º 1
0
def add(
    dispatcher,
    thread_pool,
    consensus_proxy,
    consensus_notifier,
):

    handler = handlers.ConsensusRegisterHandler(consensus_proxy,
                                                consensus_notifier)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusRegisterBlockNewSyncHandler(
        consensus_proxy, consensus_notifier)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusSendToHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusBroadcastHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusInitializeBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusSummarizeBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusFinalizeBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusCancelBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusCheckBlocksHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusCheckBlocksNotifier(consensus_proxy,
                                                    consensus_notifier)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusCommitBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusIgnoreBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusFailBlockHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusBlocksGetHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusChainHeadGetHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusSettingsGetHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)

    handler = handlers.ConsensusStateGetHandler(consensus_proxy)
    dispatcher.add_handler(handler.request_type, handler, thread_pool)
Exemplo n.º 2
0
 def test_consensus_initialize_block_handler(self):
     handler = handlers.ConsensusInitializeBlockHandler(self.mock_proxy)
     request_class = handler.request_class
     request = request_class()
     request.previous_id = b"test"
     result = handler.handle(None, request.SerializeToString())
     response = result.message_out
     self.assertEqual(response.status, handler.response_class.OK)
     self.mock_proxy.initialize_block.assert_called_with(
         request.previous_id)