refactors project structure

This commit is contained in:
Sergi Delgado Segura
2019-08-09 19:42:42 +01:00
parent 1019b207ff
commit 1cde4a2a11
31 changed files with 31 additions and 29 deletions

7
.gitignore vendored
View File

@@ -1,9 +1,12 @@
.vscode/ .vscode/
.idea/
*.log *.log
.DS_Store .DS_Store
/pisa-btc/venv/* venv/
conf.py conf.py
bitcoin.conf* bitcoin.conf*
*__pycache__ *__pycache__
.pending* .pending*
pisa-btc/apps/cli/*.json apps/cli/*.json
appointments/
test.py

View File

@@ -10,11 +10,11 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python3 get-pip.py RUN python3 get-pip.py
# Add pisa files # Add pisa files
ADD pisa-btc /root/pisa-btc ADD pisa /root/pisa_btc
WORKDIR /root/pisa-btc WORKDIR /root/pisa_btc
# Export pythonpath # Export pythonpath
RUN echo export PYTHONPATH="$PYTHONPATH:/root/pisa-btc/" >> /root/.bashrc RUN echo export PYTHONPATH="$PYTHONPATH:/root/pisa_btc/" >> /root/.bashrc
# Install dependencies # Install dependencies
RUN pip3 install -r requirements.txt RUN pip3 install -r requirements.txt

View File

@@ -7,8 +7,8 @@ import json
# FIXME: HERE FOR TESTING (get_block_count). REMOVE WHEN REMOVING THE FUNCTION # FIXME: HERE FOR TESTING (get_block_count). REMOVE WHEN REMOVING THE FUNCTION
from utils.authproxy import AuthServiceProxy from pisa.utils.authproxy import AuthServiceProxy
from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT
# ToDo: #5-add-async-to-api # ToDo: #5-add-async-to-api
app = Flask(__name__) app = Flask(__name__)
@@ -61,13 +61,13 @@ def get_appointment():
locator = request.args.get('locator') locator = request.args.get('locator')
response = [] response = []
job_in_watcher = watcher.appointments.get(locator) appointment_in_watcher = watcher.appointments.get(locator)
if job_in_watcher: if appointment_in_watcher:
for job in job_in_watcher: for appointment in appointment_in_watcher:
job_data = job.to_json() appointment_data = appointment.to_json()
job_data['status'] = "being_watched" appointment_data['status'] = "being_watched"
response.append(job_data) response.append(appointment_data)
if watcher.responder: if watcher.responder:
responder_jobs = watcher.responder.jobs responder_jobs = watcher.responder.jobs

View File

@@ -1,9 +1,9 @@
import re import re
from pisa.appointment import Appointment from pisa.appointment import Appointment
from pisa import errors from pisa import errors
from utils.authproxy import AuthServiceProxy, JSONRPCException from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException
from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MIN_DISPUTE_DELTA, SUPPORTED_CIPHERS, \ from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MIN_DISPUTE_DELTA, \
SUPPORTED_HASH_FUNCTIONS SUPPORTED_CIPHERS, SUPPORTED_HASH_FUNCTIONS
class Inspector: class Inspector:

View File

@@ -1,12 +1,11 @@
import logging import logging
from sys import argv from sys import argv
from getopt import getopt from getopt import getopt
from conf import SERVER_LOG_FILE
from threading import Thread from threading import Thread
from pisa.api import start_api from pisa.api import start_api
from pisa.tools import can_connect_to_bitcoind, in_correct_network from pisa.tools import can_connect_to_bitcoind, in_correct_network
from utils.authproxy import AuthServiceProxy from pisa.utils.authproxy import AuthServiceProxy
from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, BTC_NETWORK from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, BTC_NETWORK, SERVER_LOG_FILE
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -5,8 +5,8 @@ from binascii import unhexlify
from pisa.zmq_subscriber import ZMQHandler from pisa.zmq_subscriber import ZMQHandler
from pisa.rpc_errors import * from pisa.rpc_errors import *
from pisa.tools import check_tx_in_chain from pisa.tools import check_tx_in_chain
from utils.authproxy import AuthServiceProxy, JSONRPCException from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException
from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT
CONFIRMATIONS_BEFORE_RETRY = 6 CONFIRMATIONS_BEFORE_RETRY = 6
MIN_CONFIRMATIONS = 6 MIN_CONFIRMATIONS = 6

View File

@@ -16,6 +16,7 @@ MAX_APPOINTMENTS = 100
EXPIRY_DELTA = 6 EXPIRY_DELTA = 6
MIN_DISPUTE_DELTA = 20 MIN_DISPUTE_DELTA = 20
SERVER_LOG_FILE = 'pisa.log' SERVER_LOG_FILE = 'pisa.log'
DB_PATH = 'appointments/'
# PISA-CLI # PISA-CLI
CLIENT_LOG_FILE = 'pisa.log' CLIENT_LOG_FILE = 'pisa.log'

View File

@@ -1,4 +1,4 @@
from utils.authproxy import JSONRPCException from pisa.utils.authproxy import JSONRPCException
from pisa.rpc_errors import RPC_INVALID_ADDRESS_OR_KEY from pisa.rpc_errors import RPC_INVALID_ADDRESS_OR_KEY
from http.client import HTTPException from http.client import HTTPException

View File

@@ -1,12 +1,11 @@
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from queue import Queue from queue import Queue
from threading import Thread from threading import Thread
from conf import EXPIRY_DELTA
from pisa.responder import Responder from pisa.responder import Responder
from pisa.zmq_subscriber import ZMQHandler from pisa.zmq_subscriber import ZMQHandler
from utils.authproxy import AuthServiceProxy, JSONRPCException from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException
from hashlib import sha256 from hashlib import sha256
from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MAX_APPOINTMENTS from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MAX_APPOINTMENTS, EXPIRY_DELTA
class Watcher: class Watcher:

View File

@@ -1,6 +1,6 @@
import zmq import zmq
import binascii import binascii
from conf import FEED_PROTOCOL, FEED_ADDR, FEED_PORT from pisa.conf import FEED_PROTOCOL, FEED_ADDR, FEED_PORT
# ToDo: #7-add-async-back-to-zmq # ToDo: #7-add-async-back-to-zmq
class ZMQHandler: class ZMQHandler:

0
tests/__init__.py Normal file
View File

View File

@@ -1,10 +1,10 @@
import logging import logging
from pisa.inspector import Inspector from pisa.inspector import Inspector
from pisa.appointment import Appointment from pisa.appointment import Appointment
from conf import TEST_LOG_FILE
from pisa import errors from pisa import errors
from utils.authproxy import AuthServiceProxy, JSONRPCException from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException
from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, SUPPORTED_HASH_FUNCTIONS, SUPPORTED_CIPHERS from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, SUPPORTED_HASH_FUNCTIONS, \
SUPPORTED_CIPHERS, TEST_LOG_FILE
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO, handlers=[ logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO, handlers=[
logging.FileHandler(TEST_LOG_FILE) logging.FileHandler(TEST_LOG_FILE)