Skip to content

Commit

Permalink
clean up unessential nodelist
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajdev committed Apr 26, 2024
1 parent a21029b commit 3177eca
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions src/NodeList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as State from './State'
import * as P2P from './P2P'
import * as Utils from './Utils'
import { isDeepStrictEqual } from 'util'
import * as Logger from './Logger'
import { config } from './Config'
import * as Crypto from './Crypto'
Expand All @@ -28,18 +27,6 @@ export interface ConsensusNodeListResponse {
nodeList: ConsensusNodeInfo[]
}

export interface ConsensusNodeListResponse {
nodeList: ConsensusNodeInfo[]
}

export interface ConsensusNodeMetadata {
cycleMarkerJoined: string
}

export interface SignedList {
nodeList: ConsensusNodeInfo[]
}

export interface JoinedConsensor extends ConsensusNodeInfo {
cycleJoined: string
counterRefreshed: number
Expand Down Expand Up @@ -259,7 +246,7 @@ export const removeStandbyNodes = (publicKeys: string[]): void => {
}
}

export function setStatus(status: NodeStatus, publicKeys: string[]): void {
export function setStatus(status: Exclude<NodeStatus, NodeStatus.STANDBY>, publicKeys: string[]): void {
if (publicKeys.length === 0) return
Logger.mainLogger.debug(`Updating status ${status} for nodes`, publicKeys)
for (const key of publicKeys) {
Expand Down Expand Up @@ -290,14 +277,6 @@ export function setStatus(status: NodeStatus, publicKeys: string[]): void {
// activeListByIdSorted.map((node) => node.id)
// )
break
case NodeStatus.STANDBY:
if (activeList.has(key)) {
activeList.delete(key)
activeListByIdSorted = activeListByIdSorted.filter((node) => node.publicKey === key)
}
if (syncingList.has(key)) syncingList.delete(key)
if (standbyList.has(key)) break
standbyList.set(key, node)
}
}
}
Expand Down Expand Up @@ -435,24 +414,6 @@ export function getStandbyList(): ConsensusNodeInfo[] {
return [...standbyList.values()]
}

export function getNodeInfo(node: Partial<ConsensusNodeInfo>): ConsensusNodeInfo | undefined {
// Prefer publicKey
if (node.publicKey) {
return byPublicKey[node.publicKey]
}
// Then, ipPort
else if (node.ip && node.port) {
return byIpPort[getIpPort(node as ConsensusNodeInfo)]
}
// If nothing found, return undefined
return undefined
}

export function getId(publicKey: string): string | undefined {
// eslint-disable-next-line security/detect-object-injection
return publicKeyToId[publicKey]
}

export function getNodeInfoById(id: string): ConsensusNodeInfo | undefined {
// eslint-disable-next-line security/detect-object-injection
return byId[id]
Expand Down

0 comments on commit 3177eca

Please sign in to comment.