diff --git a/onionr/api.py b/onionr/api.py
index c6047dee..3a340dc3 100755
--- a/onionr/api.py
+++ b/onionr/api.py
@@ -256,7 +256,7 @@ class API:
self.debug = debug
self._privateDelayTime = 3
- self._core = core.Core()
+ self._core = onionrInst.onionrCore
self.startTime = self._core._utils.getEpoch()
self._crypto = onionrcrypto.OnionrCrypto(self._core)
self._utils = onionrutils.OnionrUtils(self._core)
diff --git a/onionr/communicator2.py b/onionr/communicator2.py
index 873e40c7..d131e332 100755
--- a/onionr/communicator2.py
+++ b/onionr/communicator2.py
@@ -40,7 +40,7 @@ class OnionrCommunicatorDaemon:
# initalize core with Tor socks port being 3rd argument
self.proxyPort = proxyPort
- self._core = core.Core(torPort=self.proxyPort)
+ self._core = onionrInst.onionrCore
# intalize NIST beacon salt and time
self.nistSaltTimestamp = 0
@@ -93,7 +93,6 @@ class OnionrCommunicatorDaemon:
self.startTime = self._core._utils.getEpoch()
if developmentMode:
- print('enabling heartbeat')
OnionrCommunicatorTimers(self, self.heartbeat, 30)
# Set timers, function reference, seconds
@@ -485,10 +484,12 @@ class OnionrCommunicatorDaemon:
retData = onionrpeers.PeerProfiles(peer, self._core)
return retData
+ def getUptime(self):
+ return self._core._utils.getEpoch() - self.startTime
+
def heartbeat(self):
'''Show a heartbeat debug message'''
- currentTime = self._core._utils.getEpoch() - self.startTime
- logger.debug('Heartbeat. Node running for %s.' % self.daemonTools.humanReadableTime(currentTime))
+ logger.debug('Heartbeat. Node running for %s.' % self.daemonTools.humanReadableTime(self.getUptime()))
self.decrementThreadCount('heartbeat')
def daemonCommands(self):
diff --git a/onionr/core.py b/onionr/core.py
index 9c57503f..e7646396 100644
--- a/onionr/core.py
+++ b/onionr/core.py
@@ -45,6 +45,7 @@ class Core:
self.dataDir = 'data/'
try:
+ self.onionrInst = None
self.queueDB = self.dataDir + 'queue.db'
self.peerDB = self.dataDir + 'peers.db'
self.blockDB = self.dataDir + 'blocks.db'
diff --git a/onionr/onionr.py b/onionr/onionr.py
index 8523ec77..4f054a3b 100755
--- a/onionr/onionr.py
+++ b/onionr/onionr.py
@@ -74,6 +74,7 @@ class Onionr:
self.communicatorInst = None
self.onionrCore = core.Core()
+ self.onionrCore.onionrInst = self
#self.deleteRunFiles()
self.onionrUtils = onionrutils.OnionrUtils(self.onionrCore)
@@ -751,7 +752,7 @@ class Onionr:
# TODO: make runable on windows
#communicatorProc = subprocess.Popen([communicatorDaemon, 'run', str(net.socksPort)])
-
+ self.onionrCore.torPort = net.socksPort
communicatorThread = Thread(target=communicator2.startCommunicator, args=(self, str(net.socksPort)))
communicatorThread.start()
diff --git a/onionr/serializeddata.py b/onionr/serializeddata.py
index 79143374..c4063909 100644
--- a/onionr/serializeddata.py
+++ b/onionr/serializeddata.py
@@ -36,7 +36,7 @@ class SerializedData:
def getStats(self):
'''Return statistics about our node'''
stats = {}
- stats['uptime'] = int(self._core.daemonQueueSimple('localCommand', 'getuptime'))
- stats['connectedNodes'] = self._core.daemonQueueSimple('connectedPeers')
+ stats['uptime'] = self._core.onionrInst.communicatorInst.getUptime()
+ stats['connectedNodes'] = '\n'.join(self._core.onionrInst.communicatorInst.onlinePeers)
stats['blockCount'] = len(self._core.getBlockList())
return json.dumps(stats)
diff --git a/onionr/static-data/www/private/index.html b/onionr/static-data/www/private/index.html
index 12f05b85..d78140a5 100644
--- a/onionr/static-data/www/private/index.html
+++ b/onionr/static-data/www/private/index.html
@@ -17,7 +17,7 @@
Onionr Web Control Panel
-
+
Stats
Uptime:
Stored Blocks:
diff --git a/onionr/static-data/www/shared/main/stats.js b/onionr/static-data/www/shared/main/stats.js
index 6796f2b7..bd6dcb18 100644
--- a/onionr/static-data/www/shared/main/stats.js
+++ b/onionr/static-data/www/shared/main/stats.js
@@ -21,7 +21,10 @@ uptimeDisplay = document.getElementById('uptime')
connectedDisplay = document.getElementById('connectedNodes')
storedBlockDisplay = document.getElementById('storedBlocks')
-stats = JSON.parse(httpGet('getstats', webpass))
-uptimeDisplay.innerText = stats['uptime'] + ' seconds'
-connectedDisplay.innerText = stats['connectedNodes']
-storedBlockDisplay.innerText = stats['blockCount']
\ No newline at end of file
+function getStats(){
+ stats = JSON.parse(httpGet('getstats', webpass))
+ uptimeDisplay.innerText = stats['uptime'] + ' seconds'
+ connectedDisplay.innerText = stats['connectedNodes']
+ storedBlockDisplay.innerText = stats['blockCount']
+}
+getStats()
\ No newline at end of file
diff --git a/onionr/static-data/www/shared/panel.js b/onionr/static-data/www/shared/panel.js
index ea35696c..665904e8 100644
--- a/onionr/static-data/www/shared/panel.js
+++ b/onionr/static-data/www/shared/panel.js
@@ -1,8 +1,12 @@
shutdownBtn = document.getElementById('shutdownNode')
-
+refreshStatsBtn = document.getElementById('refreshStats')
shutdownBtn.onclick = function(){
if (! nowebpass){
httpGet('shutdownclean')
overlay('shutdownNotice')
}
}
+
+refreshStatsBtn.onclick = function(){
+ getStats()
+}
\ No newline at end of file