progress in removing core

master
Kevin Froman 2019-07-18 00:11:52 -05:00
parent 8163292ed9
commit e69c8dbb60
6 changed files with 32 additions and 13 deletions

View File

@ -47,9 +47,6 @@ class Core:
self.maxBlockSize = 10000000 # max block size in bytes self.maxBlockSize = 10000000 # max block size in bytes
self.onionrInst = None self.onionrInst = None
self.queueDB = self.dataDir + 'queue.db'
self.peerDB = self.dataDir + 'peers.db'
self.blockDB = self.dataDir + 'blocks.db'
self.blockDataLocation = self.dataDir + 'blocks/' self.blockDataLocation = self.dataDir + 'blocks/'
self.blockDataDB = self.blockDataLocation + 'block-data.db' self.blockDataDB = self.blockDataLocation + 'block-data.db'
self.publicApiHostFile = self.dataDir + 'public-host.txt' self.publicApiHostFile = self.dataDir + 'public-host.txt'

View File

@ -0,0 +1,11 @@
from utils import identifyhome
home = identifyhome.identify_home()
if not home.endswith('/') home += '/'
usage_file = home + 'disk-usage.txt'
block_data_location = home + 'blocks/'
public_API_host_file = home + 'public-host.txt'
private_API_host_file = home + 'private-host.txt'
bootstrap_file_location = 'static-data/bootstrap-nodes.txt'
data_nonce_file = home + 'block-nonces.dat'
forward_keys_file = home + 'forward-keys.db'

View File

@ -0,0 +1,3 @@
from coredb import daemonqueue
def do_PEX():
daemonqueue.daemon_queue_add('pex')

View File

View File

@ -17,10 +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/>.
''' '''
def get_client_API_server(core_inst): import filepaths
def get_client_API_server():
retData = '' retData = ''
try: try:
with open(core_inst.privateApiHostFile, 'r') as host: with open(filepaths.private_API_host_file, 'r') as host:
hostname = host.read() hostname = host.read()
except FileNotFoundError: except FileNotFoundError:
raise FileNotFoundError raise FileNotFoundError

View File

@ -19,14 +19,11 @@
''' '''
import urllib, requests, time import urllib, requests, time
import logger import logger
from onionrutils import getclientapiserver from . import getclientapiserver
def local_command(core_inst, command, data='', silent = True, post=False, postData = {}, maxWait=20):
'''
Send a command to the local http API server, securely. Intended for local clients, DO NOT USE for remote peers.
'''
# TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless.
hostname = '' hostname = ''
waited = 0 waited = 0
maxWait = 3
def get_hostname():
while hostname == '': while hostname == '':
try: try:
hostname = getclientapiserver.get_client_API_server(core_inst) hostname = getclientapiserver.get_client_API_server(core_inst)
@ -35,6 +32,16 @@ def local_command(core_inst, command, data='', silent = True, post=False, postDa
waited += 1 waited += 1
if waited == maxWait: if waited == maxWait:
return False return False
return hostname
hostname = get_hostname()
def local_command(core_inst, command, data='', silent = True, post=False, postData = {}, maxWait=20):
'''
Send a command to the local http API server, securely. Intended for local clients, DO NOT USE for remote peers.
'''
# TODO: URL encode parameters, just as an extra measure. May not be needed, but should be added regardless.
if hostname == False:
hostname = get_hostname()
if data != '': if data != '':
data = '&data=' + urllib.parse.quote_plus(data) data = '&data=' + urllib.parse.quote_plus(data)
payload = 'http://%s/%s%s' % (hostname, command, data) payload = 'http://%s/%s%s' % (hostname, command, data)