Skip to content
Snippets Groups Projects
Commit e1e4af2e authored by Vincent Texier's avatar Vincent Texier
Browse files

[enh] fix current_buid declared twice in processors/nodes.py

parent 81515f5e
No related branches found
No related tags found
1 merge request!778Release 0.51.0
import attr import attr
import sqlite3 import sqlite3
from duniterpy.documents.ws2p.heads import HeadV1, HeadV2 from duniterpy.documents.ws2p.heads import HeadV2
from sakia.constants import ROOT_SERVERS from sakia.constants import ROOT_SERVERS
from ..entities import Node from ..entities import Node
...@@ -33,6 +33,10 @@ class NodesProcessor: ...@@ -33,6 +33,10 @@ class NodesProcessor:
def current_buid(self, currency): def current_buid(self, currency):
""" """
Get current buid Get current buid
Get the latest block considered valid
It is the most frequent last block of every known nodes
:param str currency: :param str currency:
""" """
current_buid = self._repo.current_buid(currency=currency) current_buid = self._repo.current_buid(currency=currency)
...@@ -104,6 +108,8 @@ class NodesProcessor: ...@@ -104,6 +108,8 @@ class NodesProcessor:
def unknown_node(self, currency, pubkey): def unknown_node(self, currency, pubkey):
""" """
Search for pubkey in the repository. Search for pubkey in the repository.
:param str currency: Name of currency
:param str pubkey: the pubkey to lookup :param str pubkey: the pubkey to lookup
""" """
other_node = self._repo.get_one(currency=currency, pubkey=pubkey) other_node = self._repo.get_one(currency=currency, pubkey=pubkey)
...@@ -121,17 +127,6 @@ class NodesProcessor: ...@@ -121,17 +127,6 @@ class NodesProcessor:
""" """
return self._repo.get_all(currency=currency, root=True) return self._repo.get_all(currency=currency, root=True)
def current_buid(self, currency):
"""
Get the latest block considered valid
It is the most frequent last block of every known nodes
"""
blocks_uids = [n.current_buid for n in self.synced_nodes(currency)]
if len(blocks_uids) > 0:
return blocks_uids[0]
else:
return BlockUID.empty()
def quality(self, currency): def quality(self, currency):
""" """
Get a ratio of the synced nodes vs the rest Get a ratio of the synced nodes vs the rest
......
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