From f843ccc3b28253a707a631fae905913be2794dd2 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 20 Jul 2019 16:21:03 -0500 Subject: [PATCH] progress in removing core --- onionr/coredb/blockmetadb/__init__.py | 1 + onionr/onionrblocks/insert.py | 2 +- onionr/static-data/default-plugins/flow/main.py | 11 ++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/onionr/coredb/blockmetadb/__init__.py b/onionr/coredb/blockmetadb/__init__.py index 96ccdfaa..729bd9f3 100644 --- a/onionr/coredb/blockmetadb/__init__.py +++ b/onionr/coredb/blockmetadb/__init__.py @@ -20,6 +20,7 @@ import sqlite3 from . import expiredblocks, updateblockinfo, add from .. import dbfiles +update_block_info = updateblockinfo.update_block_info def get_block_list(dateRec = None, unsaved = False): ''' Get list of our blocks diff --git a/onionr/onionrblocks/insert.py b/onionr/onionrblocks/insert.py index 073ae9e0..af49f8e8 100644 --- a/onionr/onionrblocks/insert.py +++ b/onionr/onionrblocks/insert.py @@ -124,7 +124,7 @@ def insert_block(data, header='txt', sign=False, encryptType='', symKey='', asym payload = onionrproofs.POW(metadata, data).waitForResult() if payload != False: try: - retData = onionrstorage.setdata.set_data(data) + retData = onionrstorage.setdata.set_data(payload) except onionrexceptions.DiskAllocationReached: logger.error(allocationReachedMessage) retData = False diff --git a/onionr/static-data/default-plugins/flow/main.py b/onionr/static-data/default-plugins/flow/main.py index 4d5954b7..f96006fd 100755 --- a/onionr/static-data/default-plugins/flow/main.py +++ b/onionr/static-data/default-plugins/flow/main.py @@ -22,7 +22,7 @@ import threading, time, locale, sys, os from onionrblockapi import Block import logger, config, onionrblocks -from onionrutils import escapeansi, epoch +from onionrutils import escapeansi, epoch, bytesconverter locale.setlocale(locale.LC_ALL, '') from coredb import blockmetadb sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) @@ -73,10 +73,11 @@ class OnionrFlow: try: while self.flowRunning: for block in blockmetadb.get_blocks_by_type('txt'): - block = Block(block) - if block.getMetadata('ch') != self.channel: + if block in self.alreadyOutputed: continue - if block.getHash() in self.alreadyOutputed: + block = Block(block) + b_hash = bytesconverter.bytes_to_str(block.getHash()) + if block.getMetadata('ch') != self.channel: continue if not self.flowRunning: break @@ -85,7 +86,7 @@ class OnionrFlow: # Escape new lines, remove trailing whitespace, and escape ansi sequences content = escapeansi.escape_ANSI(content.replace('\n', '\\n').replace('\r', '\\r').strip()) logger.info(block.getDate().strftime("%m/%d %H:%M") + ' - ' + logger.colors.reset + content, prompt = False, terminal=True) - self.alreadyOutputed.append(block.getHash()) + self.alreadyOutputed.append(b_hash) time.sleep(5) except KeyboardInterrupt: self.flowRunning = False