mirror of
https://github.com/hanzoai/bootnode.git
synced 2026-09-30 20:46:32 +00:00
Add helper to get last block number
This commit is contained in:
@@ -36,7 +36,8 @@ class Bootnode(object):
|
||||
|
||||
def synced_pod(self, network=None):
|
||||
pod = self.kube.synced_pod(network=network)
|
||||
print('{0}\t{1}\t{2}'.format(pod.name, pod.phase, pod.ip))
|
||||
print('{0}\t{1}\t{2}\t{3}'.format(pod.name, pod.phase,
|
||||
pod.block_number(), pod.ip))
|
||||
|
||||
def scale_up(args):
|
||||
pass
|
||||
|
||||
+11
-6
@@ -25,19 +25,24 @@ class Pod(object):
|
||||
else:
|
||||
self.number = -1
|
||||
|
||||
def synced(self):
|
||||
def exec(self, js):
|
||||
command = [
|
||||
'/bin/geth',
|
||||
'--datadir=/data',
|
||||
'attach',
|
||||
'--exec',
|
||||
'eth.syncing',
|
||||
js
|
||||
]
|
||||
return self.api.exec(self.name, command).lower()
|
||||
|
||||
if self.api.exec(self.name, command).lower() == 'false':
|
||||
return True
|
||||
else:
|
||||
def syncing(self):
|
||||
if self.exec('eth.syncing').lower() == 'false':
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def block_number(self):
|
||||
return int(self.exec('eth.blockNumber'))
|
||||
|
||||
def __repr__(self):
|
||||
return self.name
|
||||
@@ -71,5 +76,5 @@ class Kubernetes(object):
|
||||
def synced_pod(self, network=None):
|
||||
pods = self.list_pods(network)
|
||||
for pod in sorted(pods, key=lambda x: x.number):
|
||||
if pod.synced():
|
||||
if not pod.syncing():
|
||||
return pod
|
||||
|
||||
Reference in New Issue
Block a user