teos - feed_* -> btc_feed_*

This commit is contained in:
Sergi Delgado Segura
2020-06-09 09:24:00 +02:00
parent d91e9bb534
commit 10da7d2a10
7 changed files with 31 additions and 14 deletions

View File

@@ -30,4 +30,12 @@ if [[ ! -z ${BTC_RPC_PORT} ]]; then
START_COMMAND=$START_COMMAND" --btcrpcport=""$BTC_RPC_PORT" START_COMMAND=$START_COMMAND" --btcrpcport=""$BTC_RPC_PORT"
fi fi
if [[ ! -z ${BTC_FEED_CONNECT} ]]; then
START_COMMAND=$START_COMMAND" --btcfeedconnect=""$BTC_FEED_CONNECT"
fi
if [[ ! -z ${BTC_FEED_PORT} ]]; then
START_COMMAND=$START_COMMAND" --btcfeedport=""$BTC_FEED_PORT"
fi
$START_COMMAND $START_COMMAND

View File

@@ -13,9 +13,9 @@ DEFAULT_CONF = {
"BTC_RPC_CONNECT": {"value": "127.0.0.1", "type": str}, "BTC_RPC_CONNECT": {"value": "127.0.0.1", "type": str},
"BTC_RPC_PORT": {"value": 8332, "type": int}, "BTC_RPC_PORT": {"value": 8332, "type": int},
"BTC_NETWORK": {"value": "mainnet", "type": str}, "BTC_NETWORK": {"value": "mainnet", "type": str},
"FEED_PROTOCOL": {"value": "tcp", "type": str}, "BTC_FEED_PROTOCOL": {"value": "tcp", "type": str},
"FEED_CONNECT": {"value": "127.0.0.1", "type": str}, "BTC_FEED_CONNECT": {"value": "localhost", "type": str},
"FEED_PORT": {"value": 28332, "type": int}, "BTC_FEED_PORT": {"value": 28332, "type": int},
"MAX_APPOINTMENTS": {"value": 1000000, "type": int}, "MAX_APPOINTMENTS": {"value": 1000000, "type": int},
"DEFAULT_SLOTS": {"value": 100, "type": int}, "DEFAULT_SLOTS": {"value": 100, "type": int},
"DEFAULT_SUBSCRIPTION_DURATION": {"value": 4320, "type": int}, "DEFAULT_SUBSCRIPTION_DURATION": {"value": 4320, "type": int},

View File

@@ -54,9 +54,9 @@ class ChainMonitor:
self.zmqSubSocket.connect( self.zmqSubSocket.connect(
"%s://%s:%s" "%s://%s:%s"
% ( % (
bitcoind_feed_params.get("FEED_PROTOCOL"), bitcoind_feed_params.get("BTC_FEED_PROTOCOL"),
bitcoind_feed_params.get("FEED_CONNECT"), bitcoind_feed_params.get("BTC_FEED_CONNECT"),
bitcoind_feed_params.get("FEED_PORT"), bitcoind_feed_params.get("BTC_FEED_PORT"),
) )
) )

View File

@@ -6,9 +6,9 @@ btc_rpc_port = 8332
btc_network = mainnet btc_network = mainnet
# [zmq] # [zmq]
feed_protocol = tcp btc_feed_protocol = tcp
feed_connect = 127.0.0.1 btc_feed_connect = localhost
feed_port = 28332 btc_feed_port = 28332
[teos] [teos]
api_bind = localhost api_bind = localhost

View File

@@ -52,7 +52,7 @@ def main(command_line_conf):
logger.info("Starting TEOS") logger.info("Starting TEOS")
bitcoind_connect_params = {k: v for k, v in config.items() if k.startswith("BTC")} bitcoind_connect_params = {k: v for k, v in config.items() if k.startswith("BTC")}
bitcoind_feed_params = {k: v for k, v in config.items() if k.startswith("FEED")} bitcoind_feed_params = {k: v for k, v in config.items() if k.startswith("BTC_FEED")}
if not can_connect_to_bitcoind(bitcoind_connect_params): if not can_connect_to_bitcoind(bitcoind_connect_params):
logger.error("Cannot connect to bitcoind. Shutting down") logger.error("Cannot connect to bitcoind. Shutting down")
@@ -180,6 +180,8 @@ if __name__ == "__main__":
"btcrpcpassword=", "btcrpcpassword=",
"btcrpcconnect=", "btcrpcconnect=",
"btcrpcport=", "btcrpcport=",
"btcfeedconnect=",
"btcfeedport=",
"datadir=", "datadir=",
"help", "help",
], ],
@@ -205,6 +207,13 @@ if __name__ == "__main__":
command_line_conf["BTC_RPC_PORT"] = int(arg) command_line_conf["BTC_RPC_PORT"] = int(arg)
except ValueError: except ValueError:
exit("btcrpcport must be an integer") exit("btcrpcport must be an integer")
if opt in ["--btcfeedconnect"]:
command_line_conf["BTC_FEED_CONNECT"] = arg
if opt in ["--btcfeedport"]:
try:
command_line_conf["BTC_FEED_PORT"] = int(arg)
except ValueError:
exit("btcfeedport must be an integer")
if opt in ["--datadir"]: if opt in ["--datadir"]:
command_line_conf["DATA_DIR"] = os.path.expanduser(arg) command_line_conf["DATA_DIR"] = os.path.expanduser(arg)
if opt in ["-h", "--help"]: if opt in ["-h", "--help"]:

View File

@@ -6,9 +6,9 @@ btc_rpc_port = 18445
btc_network = regtest btc_network = regtest
# [zmq] # [zmq]
feed_protocol = tcp btc_feed_protocol = tcp
feed_connect = 127.0.0.1 btc_feed_connect = 127.0.0.1
feed_port = 28335 btc_feed_port = 28335
[teos] [teos]
max_appointments = 100 max_appointments = 100

View File

@@ -29,7 +29,7 @@ DEFAULT_CONF["BTC_RPC_PORT"]["value"] = 18443
DEFAULT_CONF["BTC_NETWORK"]["value"] = "regtest" DEFAULT_CONF["BTC_NETWORK"]["value"] = "regtest"
bitcoind_connect_params = {k: v["value"] for k, v in DEFAULT_CONF.items() if k.startswith("BTC")} bitcoind_connect_params = {k: v["value"] for k, v in DEFAULT_CONF.items() if k.startswith("BTC")}
bitcoind_feed_params = {k: v["value"] for k, v in DEFAULT_CONF.items() if k.startswith("FEED")} bitcoind_feed_params = {k: v["value"] for k, v in DEFAULT_CONF.items() if k.startswith("BTC_FEED")}
@pytest.fixture(scope="session") @pytest.fixture(scope="session")