Skip to content

Commit 20f7448

Browse files
committed
update getAllNodes
1 parent a037a64 commit 20f7448

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

src/localServer/testMinerV2.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,25 @@ const getAllNodes = async () => {
7777
})
7878
}
7979
const GuardianNodesInfo = new ethers.Contract(GuardianNodesInfoV6, NodesInfoABI, provider)
80-
80+
let i = 0
8181
await mapLimit(Guardian_Nodes, 5, async (n: nodeInfo, next) => {
82+
i = n.nftNumber
8283
const nodeInfo = await GuardianNodesInfo.getNodeInfoById(n.nftNumber)
83-
n.region = nodeInfo.regionName
84-
n.ip_addr = nodeInfo.ipaddress
85-
n.armoredPublicKey = Buffer.from(nodeInfo.pgp,'base64').toString()
86-
const pgpKey1 = await readKey({ armoredKey: n.armoredPublicKey})
87-
n.domain = pgpKey1.getKeyIDs()[1].toHex().toUpperCase() + '.conet.network'
84+
if (nodeInfo?.pgpArmored){
85+
n.region = nodeInfo.regionName
86+
n.ip_addr = nodeInfo.ipaddress
87+
n.armoredPublicKey = Buffer.from(nodeInfo.pgp,'base64').toString()
88+
const pgpKey1 = await readKey({ armoredKey: n.armoredPublicKey})
89+
n.domain = pgpKey1.getKeyIDs()[1].toHex().toUpperCase() + '.conet.network'
90+
} else {
91+
throw new Error('')
92+
}
93+
94+
}).catch(ex=> {
95+
8896
})
89-
97+
const index = Guardian_Nodes.findIndex(n => n.nftNumber === i) - 1
98+
Guardian_Nodes = Guardian_Nodes.slice(0, index)
9099
getAllNodesProcess = false
91100
}
92101

src/localServer/workers/utilities/miningV2.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,25 @@ const getAllNodes = async () => {
3434
})
3535
}
3636
const GuardianNodesInfo = new ethers.Contract(CONET_Guardian_NodeInfoV6, CONET_Guardian_NodeInfo_ABI, provideCONET)
37-
37+
let i = 0
3838
await async.mapLimit(Guardian_Nodes, 5, async (n: nodes_info, next) => {
39+
3940
const nodeInfo = await GuardianNodesInfo.getNodeInfoById(n.nftNumber)
40-
n.region = nodeInfo.regionName
41-
n.ip_addr = nodeInfo.ipaddress
42-
n.armoredPublicKey = buffer.Buffer.from(nodeInfo.pgp,'base64').toString()
43-
const pgpKey1 = await openpgp.readKey({ armoredKey: n.armoredPublicKey})
44-
n.domain = pgpKey1.getKeyIDs()[1].toHex().toUpperCase() + '.conet.network'
41+
if (nodeInfo?.pgp) {
42+
i = n.nftNumber
43+
n.region = nodeInfo.regionName
44+
n.ip_addr = nodeInfo.ipaddress
45+
n.armoredPublicKey = buffer.Buffer.from(nodeInfo.pgp,'base64').toString()
46+
const pgpKey1 = await openpgp.readKey({ armoredKey: n.armoredPublicKey})
47+
n.domain = pgpKey1.getKeyIDs()[1].toHex().toUpperCase() + '.conet.network'
48+
} else {
49+
throw new Error('')
50+
}
51+
}).catch (ex => {
4552

4653
})
54+
const index = Guardian_Nodes.findIndex(n => n.nftNumber === i)+1
55+
Guardian_Nodes = Guardian_Nodes.slice(0, index)
4756
getAllNodesProcess = false
4857
}
4958

0 commit comments

Comments
 (0)