mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-24 03:45:38 +08:00
clean up constants a bit--use relative directories, and add p2sh size estimations
This commit is contained in:
@@ -37,8 +37,8 @@ import virtualchain
|
||||
from .backend.utxo import *
|
||||
from .constants import *
|
||||
|
||||
def get_logger(debug=DEBUG):
|
||||
logger = virtualchain.get_logger('blockstack-client')
|
||||
def get_logger(name="blockstack-client", debug=DEBUG):
|
||||
logger = virtualchain.get_logger(name)
|
||||
logger.setLevel(logging.DEBUG if debug else logging.INFO)
|
||||
return logger
|
||||
|
||||
@@ -645,7 +645,7 @@ def read_config_file(path=CONFIG_PATH):
|
||||
|
||||
# try to create
|
||||
if path is not None:
|
||||
dirname = os.path.dirname(CONFIG_PATH)
|
||||
dirname = os.path.dirname(path)
|
||||
if not os.path.exists(dirname):
|
||||
os.makedirs(dirname)
|
||||
if not os.path.isdir(dirname):
|
||||
@@ -655,17 +655,17 @@ def read_config_file(path=CONFIG_PATH):
|
||||
if client_uuid is None:
|
||||
raise Exception("Failed to get client device ID")
|
||||
|
||||
config_dir = os.path.dirname(path)
|
||||
if path is None or not os.path.exists(path):
|
||||
|
||||
parser = SafeConfigParser()
|
||||
parser.add_section('blockstack-client')
|
||||
parser.set('blockstack-client', 'server', str(BLOCKSTACKD_SERVER))
|
||||
parser.set('blockstack-client', 'port', str(BLOCKSTACKD_PORT))
|
||||
parser.set('blockstack-client', 'metadata', BLOCKSTACK_METADATA_DIR)
|
||||
parser.set('blockstack-client', 'metadata', METADATA_DIRNAME)
|
||||
parser.set('blockstack-client', 'storage_drivers', BLOCKSTACK_DEFAULT_STORAGE_DRIVERS)
|
||||
parser.set('blockstack-client', 'storage_drivers_local', 'disk')
|
||||
parser.set('blockstack-client', 'storage_drivers_required_write', BLOCKSTACK_REQUIRED_STORAGE_DRIVERS_WRITE)
|
||||
parser.set('blockstack-client', 'blockchain_headers', SPV_HEADERS_PATH)
|
||||
parser.set('blockstack-client', 'advanced_mode', 'false')
|
||||
parser.set('blockstack-client', 'api_endpoint_port', str(DEFAULT_API_PORT))
|
||||
parser.set('blockstack-client', 'queue_path', str(DEFAULT_QUEUE_PATH))
|
||||
|
||||
@@ -277,23 +277,29 @@ RPC_MAX_PROFILE_LEN = 1024000 # 1MB
|
||||
CONFIG_FILENAME = 'client.ini'
|
||||
WALLET_FILENAME = 'wallet.json'
|
||||
|
||||
CONFIG_PATH = os.environ.get('BLOCKSTACK_CLIENT_CONFIG')
|
||||
|
||||
if not BLOCKSTACK_TEST:
|
||||
CONFIG_DIR = os.path.expanduser('~/.blockstack')
|
||||
CONFIG_PATH = os.path.join(CONFIG_DIR, CONFIG_FILENAME)
|
||||
# production
|
||||
if CONFIG_PATH is None:
|
||||
# default
|
||||
CONFIG_DIR = os.path.expanduser("~/.blockstack")
|
||||
CONFIG_PATH = os.path.join(CONFIG_DIR, CONFIG_FILENAME)
|
||||
|
||||
else:
|
||||
# env value
|
||||
CONFIG_DIR = os.path.dirname(CONFIG_PATH)
|
||||
else:
|
||||
# testing
|
||||
CONFIG_PATH = os.environ.get('BLOCKSTACK_CLIENT_CONFIG')
|
||||
assert CONFIG_PATH, 'BLOCKSTACK_CLIENT_CONFIG not set'
|
||||
|
||||
CONFIG_DIR = os.path.dirname(CONFIG_PATH)
|
||||
print('TEST ACTIVE: CONFIG_PATH = {}'.format(CONFIG_PATH))
|
||||
|
||||
BLOCKSTACK_METADATA_DIR = os.path.join( os.path.dirname(CONFIG_PATH), "metadata" )
|
||||
|
||||
WALLET_PATH = os.path.join(CONFIG_DIR, 'wallet.json')
|
||||
SPV_HEADERS_PATH = os.path.join(CONFIG_DIR, 'blockchain-headers.dat')
|
||||
DEFAULT_QUEUE_PATH = os.path.join(CONFIG_DIR, 'queues.db')
|
||||
|
||||
METADATA_DIRNAME = 'metadata'
|
||||
APP_ACCOUNT_DIRNAME = 'accounts'
|
||||
USER_DIRNAME = 'accounts'
|
||||
DATASTORE_DIRNAME = 'datastores'
|
||||
@@ -323,8 +329,10 @@ APPROX_REVOKE_TX_LEN = 1240
|
||||
|
||||
# for estimating tx lengths, when we can't generate a transaction.
|
||||
APPROX_TX_OVERHEAD_LEN = 12
|
||||
APPROX_TX_IN_P2PKH_LEN = 180
|
||||
APPROX_TX_IN_P2PKH_LEN = 150
|
||||
APPROX_TX_OUT_P2PKH_LEN = 40
|
||||
APPROX_TX_IN_P2SH_LEN = 300
|
||||
APPROX_TX_OUT_P2SH_LEN = 40
|
||||
|
||||
# epoch dates
|
||||
EPOCH_1_END_BLOCK = 436650
|
||||
|
||||
Reference in New Issue
Block a user