mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Updates teos to work with the new conf file format and redefines how objects are built
Configuration parameters are now load from a .conf file (see template.conf as an example). The code has 3 config levels: default (teos/__init__.py), config file (<data_dir>/teos.conf) and command line. Most of the config parameters are only modificable trough the config file for now. The priority order is: command line, config file, default. Objects that need config parameters are now built in teosd instead of inside other classes. Therefore teosd acts like a factory and config parameters don't have to be passed around between objects. This also implies that a lot of the object creation logic has been changed. This should simplify unit testing.
This commit is contained in:
@@ -39,13 +39,18 @@ class Carrier:
|
||||
The :class:`Carrier` is the class in charge of interacting with ``bitcoind`` to send/get transactions. It uses
|
||||
:obj:`Receipt` objects to report about the sending outcome.
|
||||
|
||||
Args:
|
||||
btc_connect_params (:obj:`dict`): a dictionary with the parameters to connect to bitcoind
|
||||
(rpc user, rpc passwd, host and port)
|
||||
|
||||
Attributes:
|
||||
issued_receipts (:obj:`dict`): a dictionary of issued receipts to prevent resending the same transaction over
|
||||
and over. It should periodically be reset to prevent it from growing unbounded.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, btc_connect_params):
|
||||
self.btc_connect_params = btc_connect_params
|
||||
self.issued_receipts = {}
|
||||
|
||||
# NOTCOVERED
|
||||
@@ -69,7 +74,7 @@ class Carrier:
|
||||
|
||||
try:
|
||||
logger.info("Pushing transaction to the network", txid=txid, rawtx=rawtx)
|
||||
bitcoin_cli().sendrawtransaction(rawtx)
|
||||
bitcoin_cli(self.btc_connect_params).sendrawtransaction(rawtx)
|
||||
|
||||
receipt = Receipt(delivered=True)
|
||||
|
||||
@@ -119,8 +124,7 @@ class Carrier:
|
||||
|
||||
return receipt
|
||||
|
||||
@staticmethod
|
||||
def get_transaction(txid):
|
||||
def get_transaction(self, txid):
|
||||
"""
|
||||
Queries transaction data to ``bitcoind`` given a transaction id.
|
||||
|
||||
@@ -134,7 +138,7 @@ class Carrier:
|
||||
"""
|
||||
|
||||
try:
|
||||
tx_info = bitcoin_cli().getrawtransaction(txid, 1)
|
||||
tx_info = bitcoin_cli(self.btc_connect_params).getrawtransaction(txid, 1)
|
||||
|
||||
except JSONRPCException as e:
|
||||
tx_info = None
|
||||
|
||||
Reference in New Issue
Block a user