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

View File

@ -23,7 +23,8 @@ from onionrutils import blockmetadata, stringvalidators, validatemetadata
from coredb import blockmetadb from coredb import blockmetadb
from . import shoulddownload from . import shoulddownload
from communicator import peeraction, onlinepeers 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): def download_blocks_from_communicator(comm_inst):
'''Use Onionr communicator instance to download blocks in the communicator's queue''' '''Use Onionr communicator instance to download blocks in the communicator's queue'''
assert isinstance(comm_inst, communicator.OnionrCommunicatorDaemon) assert isinstance(comm_inst, communicator.OnionrCommunicatorDaemon)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,8 @@ import sys
import logger import logger
from onionrutils import stringvalidators from onionrutils import stringvalidators
from onionrstorage import removeblock from onionrstorage import removeblock
import onionrblacklist from onionrblocks import onionrblacklist
def ban_block(): def ban_block():
blacklist = onionrblacklist.OnionrBlackList() blacklist = onionrblacklist.OnionrBlackList()
try: try:
@ -42,4 +43,4 @@ def ban_block():
else: else:
logger.error('Invalid block hash', terminal=True) logger.error('Invalid block hash', terminal=True)
ban_block.onionr_help = "<block hash>: deletes and blacklists a block" ban_block.onionr_help = "<block hash>: deletes and blacklists a block"

View File

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

View File

@ -19,7 +19,7 @@
''' '''
import os, uuid, time import os, uuid, time
import logger import logger
from onionrblockapi import Block from onionrblocks import onionrblockapi
from onionrutils import checkcommunicator, mnemonickeys from onionrutils import checkcommunicator, mnemonickeys
from utils import sizeutils, gethostname, getconsolewidth, identifyhome from utils import sizeutils, gethostname, getconsolewidth, identifyhome
from coredb import blockmetadb, daemonqueue, keydb from coredb import blockmetadb, daemonqueue, keydb
@ -30,7 +30,7 @@ def show_stats():
# define stats messages here # define stats messages here
totalBlocks = len(blockmetadb.get_block_list()) totalBlocks = len(blockmetadb.get_block_list())
home = identifyhome.identify_home() home = identifyhome.identify_home()
signedBlocks = len(Block.getBlocks(signed = True)) signedBlocks = len(onionrblockapi.Block.getBlocks(signed = True))
messages = { messages = {
# info about local client # 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'), '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 import logger
from onionrutils import epoch from onionrutils import epoch
from . import scoresortedpeerlist, peerprofiles from . import scoresortedpeerlist, peerprofiles
import onionrblacklist, config from onionrblocks import onionrblacklist
import config
from coredb import keydb from coredb import keydb
def peer_cleanup(): def peer_cleanup():
'''Removes peers who have been offline too long or score too low''' '''Removes peers who have been offline too long or score too low'''

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,8 @@
import subprocess, os import subprocess, os
import multiprocessing, threading, time, json import multiprocessing, threading, time, json
from multiprocessing import Pipe, Process 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 from onionrutils import bytesconverter
class SubprocessPOW: class SubprocessPOW:
def __init__(self, data, metadata, subproc_count=None): def __init__(self, data, metadata, subproc_count=None):

View File

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

View File

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

View File

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