Skip to content

Commit

Permalink
Merge pull request #753 from axone-protocol/ci/fix-peers
Browse files Browse the repository at this point in the history
Ci/fix peers
  • Loading branch information
ccamel authored May 28, 2024
2 parents a71a1a0 + b1c840c commit 3841959
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/update-peers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Update peers
on:
workflow_dispatch:

# Disable for now.
# schedule:
# - cron: "0 0 * * MON"
schedule:
- cron: "0 0 * * MON"

concurrency:
group: update-peers-${{ github.ref }}
Expand All @@ -17,8 +16,8 @@ jobs:
strategy:
matrix:
target:
- node: "http://rpc.okp.ppnv.space:36657"
chain: "nemeton-1"
- node: "https://rpc-t.okp4.nodestake.org"
chain: "drunemeton-1"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -41,7 +40,7 @@ jobs:
run: |
pip install requests
- name: Display the path
- name: Retrieve peers
shell: python
run: |
import requests
Expand All @@ -64,28 +63,32 @@ jobs:
def get_peer_address(peer):
peerId = peer['node_info']['id']
_, _, listen_addr, listen_port, _ = re.split("(.+:\/\/)?(.+):(\d+)", peer['node_info']['listen_addr'])
remoteIp = peer['remote_ip']
listen_address = peer['node_info']['listen_addr']
match = re.match(r"(?:.+:\/\/)?(?:.+):(\d+)", listen_address)
if match:
listen_port = match.group(1)
else:
raise ValueError("Invalid listen address: {}".format(listen_address))
match ip_class(remoteIp):
case IPClass.IPv4:
return f"{peerId}@{remoteIp}:{listen_port}"
case IPClass.IPv6:
return f"{peerId}[@{remoteIp}]:{listen_port}"
case _:
raise ValueError
raise ValueError("Invalid IP address: {}".format(remoteIp))
response = requests.get('${{ matrix.target.node }}/net_info?')
response.raise_for_status()
json_response = json.loads(response.text)
peers = map(
get_peer_address,
json_response['result']['peers'])
peers = map(get_peer_address, json_response['result']['peers'])
os.makedirs(os.path.dirname("./chains/${{ matrix.target.chain }}/"), exist_ok=True)
with open("./chains/${{ matrix.target.chain }}/peers.txt", 'w') as f:
for value in peers:
f.write(value)
f.write('\n')
f.write(f"{value}\n")
- name: Add & Commit changes
uses: EndBug/add-and-commit@v9
Expand Down
8 changes: 6 additions & 2 deletions chains/drunemeton-1/peers.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[email protected]:26656
[email protected]:26656
[email protected]:17656
[email protected]:55156
[email protected]:26656
[email protected]:26956
[email protected]:46656
[email protected]:27656
[email protected]:26636
[email protected]:19656
[email protected]:34656

0 comments on commit 3841959

Please sign in to comment.