Skip to content
Snippets Groups Projects
Commit 13afb0fd authored by Dariusz Kędzierski's avatar Dariusz Kędzierski
Browse files

Reputations object set by dedicated method

parent 0168a2a1
No related branches found
No related tags found
1 merge request!121Prerequisuites to Reputation api support
This commit is part of merge request !121. Comments created here will be created in the context of that merge request.
...@@ -13,7 +13,7 @@ from hive.indexer.follow import Follow ...@@ -13,7 +13,7 @@ from hive.indexer.follow import Follow
from hive.indexer.votes import Votes from hive.indexer.votes import Votes
from hive.indexer.post_data_cache import PostDataCache from hive.indexer.post_data_cache import PostDataCache
from hive.indexer.tags import Tags from hive.indexer.tags import Tags
from hive.indexer.reputations import Reputations
from time import perf_counter from time import perf_counter
...@@ -30,12 +30,11 @@ class Blocks: ...@@ -30,12 +30,11 @@ class Blocks:
"""Processes blocks, dispatches work, manages `hive_blocks` table.""" """Processes blocks, dispatches work, manages `hive_blocks` table."""
blocks_to_flush = [] blocks_to_flush = []
_head_block_date = None _head_block_date = None
_reputations = Reputations(DB) _reputations = None
_current_block_date = None _current_block_date = None
def __init__(cls): def __init__(cls):
log.info("Creating a reputations processor") log.info("Creating a reputations processor")
log.info("Built reputations object: {}".format(cls._reputations))
log.info("Built blocks object: {}".format(cls)) log.info("Built blocks object: {}".format(cls))
head_date = cls.head_date() head_date = cls.head_date()
...@@ -46,6 +45,12 @@ class Blocks: ...@@ -46,6 +45,12 @@ class Blocks:
cls._head_block_date = head_date cls._head_block_date = head_date
cls._current_block_date = head_date cls._current_block_date = head_date
@classmethod
def set_reputations_processor(cls, reputations_processor):
cls._reputations = reputations_processor
assert cls._reputations is not None, "Reputation object is None"
log.info("Built reputations object: {}".format(cls._reputations))
@classmethod @classmethod
def head_num(cls): def head_num(cls):
"""Get hive's head block number.""" """Get hive's head block number."""
......
"""Hive sync manager.""" """Hive sync manager."""
from hive.indexer.reputations import Reputations
import logging import logging
import glob import glob
from time import perf_counter as perf from time import perf_counter as perf
...@@ -31,6 +32,7 @@ from hive.utils.stats import FlushStatusManager as FSM ...@@ -31,6 +32,7 @@ from hive.utils.stats import FlushStatusManager as FSM
from hive.utils.stats import WaitingStatusManager as WSM from hive.utils.stats import WaitingStatusManager as WSM
from hive.utils.stats import PrometheusClient as PC from hive.utils.stats import PrometheusClient as PC
from hive.utils.stats import BroadcastObject from hive.utils.stats import BroadcastObject
from hive.indexer.reputations import Reputations
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -216,7 +218,7 @@ class Sync: ...@@ -216,7 +218,7 @@ class Sync:
# ensure db schema up to date, check app status # ensure db schema up to date, check app status
DbState.initialize() DbState.initialize()
Blocks.set_reputations_processor(Reputations(self._db))
self._blocksProcessor = Blocks() self._blocksProcessor = Blocks()
# prefetch id->name and id->rank memory maps # prefetch id->name and id->rank memory maps
...@@ -370,7 +372,7 @@ class Sync: ...@@ -370,7 +372,7 @@ class Sync:
start_time = perf() start_time = perf()
self._db.query("START TRANSACTION") self._db.query("START TRANSACTION")
num = blocksProcessor.process(block, {}, steemd) num = self._blocksProcessor.process(block, {}, steemd)
follows = Follow.flush(trx=False) follows = Follow.flush(trx=False)
accts = Accounts.flush(steemd, trx=False, spread=8) accts = Accounts.flush(steemd, trx=False, spread=8)
self._db.query("COMMIT") self._db.query("COMMIT")
......
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