moved block related files to onionrblocks

master
Kevin Froman 2019-09-21 18:49:24 -05:00
parent e49f311192
commit edd9bf6d3b
30 changed files with 59 additions and 39 deletions

View File

@ -20,7 +20,8 @@
'''
import sys, os, time
import config, logger
import onionrexceptions, onionrpeers, onionrblockapi as block
import onionrexceptions, onionrpeers
from onionrblocks import onionrblockapi as block
from onionrplugins import onionrevents as events
import onionrplugins as plugins
from . import onlinepeers, uploadqueue
@ -32,7 +33,8 @@ from communicatorutils import daemonqueuehandler, announcenode, deniableinserts
from communicatorutils import cooldownpeer, housekeeping, netcheck
from onionrutils import localcommand, epoch
from etc import humanreadabletime
import onionrservices, filepaths, storagecounter
import onionrservices, filepaths
from onionrblocks import storagecounter
from coredb import daemonqueue, dbfiles
from utils import gettransports
from netcontroller import NetController

View File

@ -23,7 +23,8 @@ from onionrutils import blockmetadata, stringvalidators, validatemetadata
from coredb import blockmetadb
from . import shoulddownload
from communicator import peeraction, onlinepeers
import onionrcrypto, onionrstorage, onionrblacklist, storagecounter
import onionrcrypto, onionrstorage
from onionrblocks import onionrblacklist, storagecounter
def download_blocks_from_communicator(comm_inst):
'''Use Onionr communicator instance to download blocks in the communicator's queue'''
assert isinstance(comm_inst, communicator.OnionrCommunicatorDaemon)

View File

@ -18,7 +18,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
from coredb import blockmetadb
import onionrblacklist
from onionrblocks import onionrblacklist
def should_download(comm_inst, block_hash):
blacklist = onionrblacklist.OnionrBlackList()
ret_data = True

View File

@ -24,7 +24,7 @@ from onionrutils import epoch
from coredb import blockmetadb, dbfiles
import onionrstorage
from onionrstorage import removeblock
import onionrblacklist
from onionrblocks import onionrblacklist
def __remove_from_upload(comm_inst, block_hash: str):
try:

View File

@ -22,7 +22,7 @@ from onionrutils import stringvalidators, epoch
from communicator import peeraction, onlinepeers
from coredb import blockmetadb
from utils import reconstructhash
import onionrblacklist
from onionrblocks import onionrblacklist
blacklist = onionrblacklist.OnionrBlackList()
def lookup_blocks_from_communicator(comm_inst):
logger.info('Looking up new blocks')

View File

@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import communicator, onionrblockapi
import communicator
from onionrblocks import onionrblockapi
import logger
from onionrutils import stringvalidators, bytesconverter
from coredb import blockmetadb

View File

@ -24,7 +24,7 @@ import threading
import logger
from communicatorutils import proxypicker
import onionrexceptions
import onionrblockapi as block
from onionrblocks import onionrblockapi as block
from onionrutils import localcommand, stringvalidators, basicrequests
from communicator import onlinepeers
import onionrcrypto

View File

@ -1,5 +1,5 @@
import json
import onionrblockapi
from onionrblocks import onionrblockapi
from onionrutils import bytesconverter, stringvalidators
import onionrexceptions
class GetBlockData:

View File

@ -18,7 +18,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
from flask import Blueprint, Response
import onionrblockapi, onionrexceptions
from onionrblocks import onionrblockapi
import onionrexceptions
from onionrutils import stringvalidators
from coredb import daemonqueue
shutdown_bp = Blueprint('shutdown', __name__)

View File

@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
from flask import Blueprint, Response, abort
import onionrblockapi
from onionrblocks import onionrblockapi
from .. import apiutils
from onionrutils import stringvalidators
from coredb import blockmetadb

View File

@ -19,7 +19,10 @@
'''
import sys
from flask import Response, abort
import blockimporter, onionrexceptions, logger
from onionrblocks import blockimporter
import onionrexceptions, logger
def accept_upload(request):
resp = 'failure'
data = request.get_data()

View File

@ -20,7 +20,8 @@
import base64
import binascii
from flask import Blueprint, Response, request, abort
import onionrblockapi, onionrexceptions
from onionrblocks import onionrblockapi
import onionrexceptions
from onionrutils import stringvalidators
site_api = Blueprint('siteapi', __name__)

View File

@ -20,7 +20,8 @@
import onionrexceptions, logger
from onionrutils import validatemetadata, blockmetadata
from coredb import blockmetadb
import onionrblacklist, onionrstorage
from . import onionrblacklist
import onionrstorage
import onionrcrypto as crypto
def importBlockFromData(content):
blacklist = onionrblacklist.OnionrBlackList()

View File

@ -1,7 +1,8 @@
from typing import Union
import json
from onionrutils import bytesconverter, epoch
import storagecounter, filepaths, onionrstorage
import filepaths, onionrstorage
from . import storagecounter
from onionrplugins import onionrevents as events
from etc import powchoice, onionrvalues
import config, onionrcrypto as crypto, subprocesspow, onionrexceptions

View File

@ -21,7 +21,8 @@ import sys
import logger
from onionrutils import stringvalidators
from onionrstorage import removeblock
import onionrblacklist
from onionrblocks import onionrblacklist
def ban_block():
blacklist = onionrblacklist.OnionrBlackList()
try:

View File

@ -1,9 +1,9 @@
'''
"""
Onionr - Private P2P Communication
This file handles the commands for adding and getting files from the Onionr network
'''
'''
"""
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@ -16,11 +16,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
"""
import base64, sys, os
import logger
from onionrblockapi import Block
from onionrblocks.onionrblockapi import Block
import onionrexceptions
from onionrutils import stringvalidators
from etc import onionrvalues
@ -37,9 +37,9 @@ def add_html(singleBlock=True, blockType='html'):
add_html.onionr_help = "Adds an HTML file into Onionr. Does not currently include dependant resources"
def add_file(singleBlock=False, blockType='bin'):
'''
"""
Adds a file to the onionr network
'''
"""
if len(sys.argv) >= 3:
filename = sys.argv[2]
@ -61,9 +61,9 @@ def add_file(singleBlock=False, blockType='bin'):
add_file.onionr_help = "<file path> Add a file into the Onionr network"
def get_file():
'''
"""
Get a file from onionr blocks
'''
"""
try:
fileName = _get_dir(sys.argv[2])
bHash = sys.argv[3]

View File

@ -19,7 +19,7 @@
'''
import os, uuid, time
import logger
from onionrblockapi import Block
from onionrblocks import onionrblockapi
from onionrutils import checkcommunicator, mnemonickeys
from utils import sizeutils, gethostname, getconsolewidth, identifyhome
from coredb import blockmetadb, daemonqueue, keydb
@ -30,7 +30,7 @@ def show_stats():
# define stats messages here
totalBlocks = len(blockmetadb.get_block_list())
home = identifyhome.identify_home()
signedBlocks = len(Block.getBlocks(signed = True))
signedBlocks = len(onionrblockapi.Block.getBlocks(signed = True))
messages = {
# info about local client
'Onionr Daemon Status' : ((logger.colors.fg.green + 'Online') if checkcommunicator.is_communicator_running(timeout = 9) else logger.colors.fg.red + 'Offline'),

View File

@ -21,7 +21,8 @@ import sqlite3
import logger
from onionrutils import epoch
from . import scoresortedpeerlist, peerprofiles
import onionrblacklist, config
from onionrblocks import onionrblacklist
import config
from coredb import keydb
def peer_cleanup():
'''Removes peers who have been offline too long or score too low'''

View File

@ -20,7 +20,7 @@
from coredb import keydb
from onionrutils import epoch
from onionrutils import stringvalidators
import onionrblacklist
from onionrblocks import onionrblacklist
import onionrexceptions
UPDATE_DELAY = 300

View File

@ -17,8 +17,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import multiprocessing, nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, sys, json, sys
import config, logger, onionrblockapi, storagecounter
import multiprocessing, time, math, threading, binascii, sys, json
import nacl.encoding, nacl.hash, nacl.utils
import config, logger
from onionrblocks import onionrblockapi, storagecounter
from onionrutils import bytesconverter
from onionrcrypto import hashers
config.reload()

View File

@ -2,7 +2,7 @@ import sys, sqlite3
import onionrexceptions, onionrstorage
from onionrutils import stringvalidators
from coredb import dbfiles
import storagecounter
from onionrblocks import storagecounter
def remove_block(block):
'''
remove a block from this node (does not automatically blacklist)

View File

@ -1,6 +1,7 @@
import sys, sqlite3
import onionrstorage, onionrexceptions, onionrcrypto as crypto
import filepaths, storagecounter
import filepaths
from onionrblocks import storagecounter
from coredb import dbfiles
from onionrutils import blockmetadata, bytesconverter
def set_data(data)->str:

View File

@ -19,7 +19,7 @@
'''
from etc import onionrvalues
import onionrblockapi
from onionrblocks import onionrblockapi
from .. import epoch, bytesconverter
from coredb import blockmetadb
import logger

View File

@ -22,7 +22,8 @@
import subprocess, os
import multiprocessing, threading, time, json
from multiprocessing import Pipe, Process
import onionrblockapi, config, onionrutils, logger, onionrproofs, onionrcrypto as crypto
from onionrblocks import onionrblockapi
import config, onionrutils, logger, onionrproofs, onionrcrypto as crypto
from onionrutils import bytesconverter
class SubprocessPOW:
def __init__(self, data, metadata, subproc_count=None):

View File

@ -19,7 +19,8 @@
'''
import logger
from coredb import keydb
import config, onionrblacklist
import config
from onionrblocks import onionrblacklist
from utils import gettransports
def mergeAdders(newAdderList):
'''

View File

@ -9,7 +9,7 @@ import onionrstorage
from utils import createdirs
from onionrutils import bytesconverter
import onionrcrypto
import onionrblockapi
from onionrblocks import onionrblockapi
def setup_test():
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'

View File

@ -13,7 +13,7 @@ from utils import createdirs
import onionrblocks
import filepaths
import onionrexceptions
import storagecounter
from onionrblocks import storagecounter
import onionrstorage
def _test_setup():