Skip to content

Commit

Permalink
SHARD-1065: expose other nodestatus functions to app (#343)
Browse files Browse the repository at this point in the history
* feat: expose other nodestatus functions to app

* fix: remove debug log
  • Loading branch information
PudgyPug authored Dec 9, 2024
1 parent 45e4ba5 commit a018859
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/shardus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,39 @@ class Shardus extends EventEmitter {
return true
}

isNodeReadyByPubKey(pubKey: string): boolean {
const node = this.p2p.state.getNodeByPubKey(pubKey)
if (node == null) {
return false
}
if (node.status !== NodeStatus.READY) {
return false
}
return true
}

isNodeSyncingByPubKey(pubKey: string): boolean {
const node = this.p2p.state.getNodeByPubKey(pubKey)
if (node == null) {
return false
}
if (node.status !== NodeStatus.SYNCING) {
return false
}
return true
}

isNodeSelectedByPubKey(pubKey: string): boolean {
const node = this.p2p.state.getNodeByPubKey(pubKey)
if (node == null) {
return false
}
if (node.status !== NodeStatus.SELECTED) {
return false
}
return true
}

isNodeActive(id: string): boolean {
const node = this.p2p.state.getNode(id)
if (node == null) {
Expand Down

0 comments on commit a018859

Please sign in to comment.