Skip to content

Commit 9a7a973

Browse files
committed
use constant in the bitcoin rpc function
1 parent 8301302 commit 9a7a973

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/warnet/bitcoin.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from test_framework.p2p import MESSAGEMAP
1010
from urllib3.exceptions import MaxRetryError
1111

12-
from .k8s import get_default_namespace, get_mission, get_pod
12+
from .constants import BITCOINCORE_CONTAINER
13+
from .k8s import get_default_namespace, get_mission
1314
from .process import run_command
1415

1516

@@ -39,18 +40,10 @@ def _rpc(tank: str, method: str, params: str):
3940
# so no extra args like port, chain, username or password are needed
4041
namespace = get_default_namespace()
4142

42-
try:
43-
pod = get_pod(tank)
44-
container_names = [container.name for container in pod.spec.containers]
45-
container_name = container_names[0]
46-
except Exception as e:
47-
print(f"Could not determine primary container: {e}")
48-
return
49-
5043
if params:
51-
cmd = f"kubectl -n {namespace} exec {tank} --container {container_name} -- bitcoin-cli {method} {' '.join(map(str, params))}"
44+
cmd = f"kubectl -n {namespace} exec {tank} --container {BITCOINCORE_CONTAINER} -- bitcoin-cli {method} {' '.join(map(str, params))}"
5245
else:
53-
cmd = f"kubectl -n {namespace} exec {tank} --container {container_name} -- bitcoin-cli {method}"
46+
cmd = f"kubectl -n {namespace} exec {tank} --container {BITCOINCORE_CONTAINER} -- bitcoin-cli {method}"
5447
return run_command(cmd)
5548

5649

0 commit comments

Comments
 (0)