Skip to content
Snippets Groups Projects
Commit f71bd7b5 authored by Holger's avatar Holger
Browse files

fix updatenode in shell mode

parent 5e53832a
No related branches found
No related tags found
2 merge requests!5Taken current version of master branch in the https://github.com/holgern/beem,!4Original changes pushed to master at https://github.com/holgern/beem
...@@ -4,6 +4,7 @@ Changelog ...@@ -4,6 +4,7 @@ Changelog
------ ------
* setproxy function added to Account (thanks to @flugschwein) * setproxy function added to Account (thanks to @flugschwein)
* addproxy and delproxy added to beempy (thanks to @flugschwein) * addproxy and delproxy added to beempy (thanks to @flugschwein)
* updatenodes works in shell mode
0.23.0 0.23.0
------ ------
......
...@@ -505,6 +505,10 @@ def updatenodes(show, hive, steem, test, only_https, only_wss): ...@@ -505,6 +505,10 @@ def updatenodes(show, hive, steem, test, only_https, only_wss):
print(t) print(t)
if not test: if not test:
stm.set_default_nodes(nodes) stm.set_default_nodes(nodes)
stm.rpc.nodes.set_node_urls(nodes)
stm.rpc.current_rpc = 0
stm.rpc.rpcclose()
stm.rpc.rpcconnect()
@cli.command() @cli.command()
......
...@@ -30,6 +30,11 @@ class Node(object): ...@@ -30,6 +30,11 @@ class Node(object):
class Nodes(list): class Nodes(list):
"""Stores Node URLs and error counts""" """Stores Node URLs and error counts"""
def __init__(self, urls, num_retries, num_retries_call): def __init__(self, urls, num_retries, num_retries_call):
self.set_node_urls(urls)
self.num_retries = num_retries
self.num_retries_call = num_retries_call
def set_node_urls(self, urls):
if isinstance(urls, str): if isinstance(urls, str):
url_list = re.split(r",|;", urls) url_list = re.split(r",|;", urls)
if url_list is None: if url_list is None:
...@@ -41,12 +46,10 @@ class Nodes(list): ...@@ -41,12 +46,10 @@ class Nodes(list):
elif urls is not None: elif urls is not None:
url_list = [urls] url_list = [urls]
else: else:
url_list = [] url_list = []
super(Nodes, self).__init__([Node(x) for x in url_list]) super(Nodes, self).__init__([Node(x) for x in url_list])
self.num_retries = num_retries
self.num_retries_call = num_retries_call
self.current_node_index = -1 self.current_node_index = -1
self.freeze_current_node = False self.freeze_current_node = False
def __iter__(self): def __iter__(self):
return self return self
......
...@@ -54,3 +54,12 @@ class Testcases(unittest.TestCase): ...@@ -54,3 +54,12 @@ class Testcases(unittest.TestCase):
nodes = Nodes(["a", "b", "c"], 5, 5) nodes = Nodes(["a", "b", "c"], 5, 5)
nodes2 = Nodes(nodes, 5, 5) nodes2 = Nodes(nodes, 5, 5)
self.assertEqual(nodes.url, nodes2.url) self.assertEqual(nodes.url, nodes2.url)
nodes2 = Nodes(["a", "b", "c"], 5, 5)
nodes2.set_node_urls(["a", "c"])
self.assertEqual(nodes.url, nodes2.url)
next(nodes)
next(nodes)
next(nodes)
next(nodes2)
next(nodes2)
self.assertEqual(nodes.url, nodes2.url)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment