mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
kivy: use NumericProperty for blocks and nodes
This commit is contained in:
parent
98dcc7c094
commit
08fd7d95ab
3 changed files with 8 additions and 15 deletions
|
@ -22,7 +22,7 @@ from kivy.core.window import Window
|
||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform
|
||||||
from kivy.properties import (OptionProperty, AliasProperty, ObjectProperty,
|
from kivy.properties import (OptionProperty, AliasProperty, ObjectProperty,
|
||||||
StringProperty, ListProperty, BooleanProperty)
|
StringProperty, ListProperty, BooleanProperty, NumericProperty)
|
||||||
from kivy.cache import Cache
|
from kivy.cache import Cache
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
|
@ -75,6 +75,8 @@ class ElectrumWindow(App):
|
||||||
electrum_config = ObjectProperty(None)
|
electrum_config = ObjectProperty(None)
|
||||||
|
|
||||||
language = StringProperty('en')
|
language = StringProperty('en')
|
||||||
|
num_blocks = NumericProperty(0)
|
||||||
|
num_nodes = NumericProperty(0)
|
||||||
|
|
||||||
def set_URI(self, uri):
|
def set_URI(self, uri):
|
||||||
self.switch_to('send')
|
self.switch_to('send')
|
||||||
|
@ -532,6 +534,8 @@ class ElectrumWindow(App):
|
||||||
|
|
||||||
def on_network(self, event, *args):
|
def on_network(self, event, *args):
|
||||||
if event == 'updated':
|
if event == 'updated':
|
||||||
|
self.num_blocks = self.network.get_local_height()
|
||||||
|
self.num_nodes = len(self.network.get_interfaces())
|
||||||
self._trigger_update_wallet()
|
self._trigger_update_wallet()
|
||||||
elif event == 'status':
|
elif event == 'status':
|
||||||
self._trigger_update_status()
|
self._trigger_update_status()
|
||||||
|
|
|
@ -22,11 +22,11 @@ Builder.load_string('''
|
||||||
TopLabel:
|
TopLabel:
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
id: bc_height
|
id: bc_height
|
||||||
text: ''
|
text: _("Verified headers: %d blocks.")% app.num_blocks
|
||||||
TopLabel:
|
TopLabel:
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
id: bc_status
|
id: bc_status
|
||||||
text: ''
|
text: _("Connected to %d nodes.")% app.num_nodes if app.num_nodes else _("Not connected?")
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
TopLabel:
|
TopLabel:
|
||||||
|
@ -88,12 +88,6 @@ class CheckpointDialog(Factory.Popup):
|
||||||
self.cp_height, self.cp_value = self.network.blockchain.get_checkpoint()
|
self.cp_height, self.cp_value = self.network.blockchain.get_checkpoint()
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
|
|
||||||
n_nodes = len(network.get_interfaces())
|
|
||||||
n_blocks = network.get_local_height()
|
|
||||||
self.ids.bc_height.text = _("Verified headers: %d blocks.")%n_blocks
|
|
||||||
self.ids.bc_status.text = _("Connected to %d nodes.")%n_nodes if n_nodes else _("Not connected?")
|
|
||||||
|
|
||||||
|
|
||||||
def on_height_str(self):
|
def on_height_str(self):
|
||||||
try:
|
try:
|
||||||
new_height = int(self.ids.height_input.text)
|
new_height = int(self.ids.height_input.text)
|
||||||
|
|
|
@ -121,7 +121,7 @@ Builder.load_string('''
|
||||||
action: partial(root.coinselect_dialog, self)
|
action: partial(root.coinselect_dialog, self)
|
||||||
CardSeparator
|
CardSeparator
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: root.blockchain_status()
|
status: "%d blocks"% app.num_blocks
|
||||||
title: _('Blockchain') + ': ' + self.status
|
title: _('Blockchain') + ': ' + self.status
|
||||||
description: _("Configure checkpoints")
|
description: _("Configure checkpoints")
|
||||||
action: partial(root.blockchain_dialog, self)
|
action: partial(root.blockchain_dialog, self)
|
||||||
|
@ -191,17 +191,12 @@ class SettingsDialog(Factory.Popup):
|
||||||
self._coinselect_dialog = ChoiceDialog(_('Coin selection'), choosers, chooser_name, cb)
|
self._coinselect_dialog = ChoiceDialog(_('Coin selection'), choosers, chooser_name, cb)
|
||||||
self._coinselect_dialog.open()
|
self._coinselect_dialog.open()
|
||||||
|
|
||||||
def blockchain_status(self):
|
|
||||||
height = self.app.network.get_local_height()
|
|
||||||
return "%d blocks"% height
|
|
||||||
|
|
||||||
def blockchain_dialog(self, item, dt):
|
def blockchain_dialog(self, item, dt):
|
||||||
from checkpoint_dialog import CheckpointDialog
|
from checkpoint_dialog import CheckpointDialog
|
||||||
if self._blockchain_dialog is None:
|
if self._blockchain_dialog is None:
|
||||||
def callback(height, value):
|
def callback(height, value):
|
||||||
if value:
|
if value:
|
||||||
self.app.network.blockchain.set_checkpoint(height, value)
|
self.app.network.blockchain.set_checkpoint(height, value)
|
||||||
item.status = self.blockchain_status()
|
|
||||||
self._blockchain_dialog = CheckpointDialog(self.app.network, callback)
|
self._blockchain_dialog = CheckpointDialog(self.app.network, callback)
|
||||||
self._blockchain_dialog.open()
|
self._blockchain_dialog.open()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue