コード例 #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)
コード例 #2
0
ファイル: tests.py プロジェクト: bestonly125/DGT-Kawartha
 def test_consensus_settings_get_handler(self):
     self.mock_proxy.settings_get.return_value = [('key', 'value')]
     handler = handlers.ConsensusSettingsGetHandler(self.mock_proxy)
     request_class = handler.request_class
     request = request_class()
     request.block_id = b"test"
     request.keys.extend(["test"])
     result = handler.handle(None, request.SerializeToString())
     response = result.message_out
     self.assertEqual(response.status, handler.response_class.OK)
     self.mock_proxy.settings_get.assert_called_with(
         request.block_id, request.keys)