Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #90 from icon-project/develop
Browse files Browse the repository at this point in the history
RC2.0.3
  • Loading branch information
June Park authored Feb 13, 2019
2 parents e51294c + 075e7b0 commit 3de4364
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions loopchain/channel/channel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion loopchain/configure_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions loopchain/peer/peer_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
Expand All @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions loopchain/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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}"
return url


Expand Down

0 comments on commit 3de4364

Please sign in to comment.