From ac6efcc1e483c27b9cc151627f463649b41983f5 Mon Sep 17 00:00:00 2001 From: Jiyun Park Date: Wed, 13 Feb 2019 10:15:16 +0900 Subject: [PATCH 1/5] [LC-77] fix bug in v1 multichannel request --- loopchain/utils/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/loopchain/utils/__init__.py b/loopchain/utils/__init__.py index e3a4a14e9..1c6b26927 100644 --- a/loopchain/utils/__init__.py +++ b/loopchain/utils/__init__.py @@ -278,10 +278,10 @@ def generate_url_from_params(ip=None, dns=None, port=None, version=None, use_htt ip = dns port = '443' - if version == conf.ApiVersion.v2: - url = f"{'https' if use_https else 'http'}://{ip}:{port}/api/{version.name}" - else: # ApiVersion.v3 or ApiVersion.node + if version == (conf.ApiVersion.v3 or conf.ApiVersion.node): url = f"{'https' if use_https else 'http'}://{ip}:{port}/api/{version.name}/{channel}" + else: # ApiVersion.v1 or ApiVersion.v2 + url = f"{'https' if use_https else 'http'}://{ip}:{port}/api/{version.name}" return url From 273c28b0dc1f57680994ce392de9404bad14a552 Mon Sep 17 00:00:00 2001 From: Jiyun Park Date: Wed, 13 Feb 2019 11:23:36 +0900 Subject: [PATCH 2/5] [LC-77] fix bug in generate_url --- loopchain/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopchain/utils/__init__.py b/loopchain/utils/__init__.py index 1c6b26927..1147e430d 100644 --- a/loopchain/utils/__init__.py +++ b/loopchain/utils/__init__.py @@ -278,7 +278,7 @@ def generate_url_from_params(ip=None, dns=None, port=None, version=None, use_htt ip = dns port = '443' - if version == (conf.ApiVersion.v3 or conf.ApiVersion.node): + if version in (conf.ApiVersion.v3, conf.ApiVersion.node): url = f"{'https' if use_https else 'http'}://{ip}:{port}/api/{version.name}/{channel}" else: # ApiVersion.v1 or ApiVersion.v2 url = f"{'https' if use_https else 'http'}://{ip}:{port}/api/{version.name}" From 3dddc08d7253c9aa03422d427db38d1914e26a61 Mon Sep 17 00:00:00 2001 From: Jiyun Park Date: Wed, 13 Feb 2019 17:42:47 +0900 Subject: [PATCH 3/5] [LC-173] add channel filter when loading channels json file by peer --- loopchain/configure_default.py | 2 +- loopchain/peer/peer_service.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/loopchain/configure_default.py b/loopchain/configure_default.py index 9bda831bc..0a79dce51 100644 --- a/loopchain/configure_default.py +++ b/loopchain/configure_default.py @@ -334,7 +334,7 @@ def is_support_node_function(cls, node_function, node_type): LOOPCHAIN_DEFAULT_CHANNEL = "icon_dex" # Default Channel Name LOOPCHAIN_TEST_CHANNEL = "loopchain_test" CHANNEL_MANAGE_DATA_PATH = os.path.join(LOOPCHAIN_ROOT_PATH, 'channel_manage_data.json') # Channel Manage Data Path -ENABLE_CHANNEL_AUTH = False # if this option is true, peer only gets channel infos to which it belongs. +ENABLE_CHANNEL_AUTH = True # if this option is true, peer only gets channel infos to which it belongs. ENABLE_REP_RADIO_STATION = False CHANNEL_RESTART_TIMEOUT = 120 CHANNEL_BUILTIN = True diff --git a/loopchain/peer/peer_service.py b/loopchain/peer/peer_service.py index b00d83b7e..1cfe65543 100644 --- a/loopchain/peer/peer_service.py +++ b/loopchain/peer/peer_service.py @@ -209,6 +209,12 @@ def __get_channel_infos(self): json_string = json.dumps(json_data).replace('[local_ip]', util.get_private_ip()) channels = json.loads(json_string) + if conf.ENABLE_CHANNEL_AUTH: + filtered_channels = {channel: channels[channel] for channel in channels + for peer in channels[channel]['peers'] + if self.__peer_id == peer['id']} + channels = filtered_channels + logging.info(f"loading channel info : {json_data}") except FileNotFoundError as e: util.exit_and_msg(f"cannot open json file in ({conf.CHANNEL_MANAGE_DATA_PATH}): {e}") @@ -318,6 +324,7 @@ def serve(self, self.__init_kms_helper(agent_pin) self.__init_port(port) self.__init_level_db() + self.__init_key_by_channel() StubCollection().amqp_target = amqp_target StubCollection().amqp_key = amqp_key @@ -331,8 +338,6 @@ def serve(self, if not self.__channel_infos: util.exit_and_msg("There is no peer_list, initial network is not allowed without RS!") - self.__init_key_by_channel() - self.__run_rest_services(port) self.run_common_service() From 4feda3907eeb4c4cd9ade82cfc6f6e5dbf3ca51e Mon Sep 17 00:00:00 2001 From: winDy Date: Wed, 13 Feb 2019 11:24:46 +0900 Subject: [PATCH 4/5] Prevent leader complain timer when peer is leader. --- loopchain/channel/channel_service.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/loopchain/channel/channel_service.py b/loopchain/channel/channel_service.py index bb3b57bd6..436ea7662 100644 --- a/loopchain/channel/channel_service.py +++ b/loopchain/channel/channel_service.py @@ -863,9 +863,10 @@ def get_object_has_queue_by_consensus(self): def start_leader_complain_timer(self): util.logger.spam(f"start_leader_complain_timer in channel service.") - self.__timer_service.add_timer_convenient(timer_key=TimerService.TIMER_KEY_LEADER_COMPLAIN, - duration=conf.TIMEOUT_FOR_LEADER_COMPLAIN, - is_repeat=True, callback=self.state_machine.leader_complain) + if self.state_machine.state != "BlockGenerate": + self.__timer_service.add_timer_convenient(timer_key=TimerService.TIMER_KEY_LEADER_COMPLAIN, + duration=conf.TIMEOUT_FOR_LEADER_COMPLAIN, + is_repeat=True, callback=self.state_machine.leader_complain) def stop_leader_complain_timer(self): util.logger.spam(f"stop_leader_complain_timer in channel service.") From 075e7b051d9708e7666d5cfff4560d7a1a876603 Mon Sep 17 00:00:00 2001 From: Jiyun Park Date: Wed, 13 Feb 2019 19:28:54 +0900 Subject: [PATCH 5/5] Update VERSION to 2.0.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e9307ca57..50ffc5aa7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.2 +2.0.3