Skip to content

Commit

Permalink
revert: undo changes for SYS-126
Browse files Browse the repository at this point in the history
  • Loading branch information
muni-corn authored and jairajdev committed Apr 26, 2024
1 parent bc33fb6 commit a21029b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Data/Cycles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function updateNodeList(cycle: P2PTypes.CycleCreatorTypes.CycleData): void {
ip: joinRequest.nodeInfo.externalIp,
port: joinRequest.nodeInfo.externalPort,
}))
NodeList.addNodes(NodeList.NodeStatus.STANDBY, standbyNodeList)
NodeList.addStandbyNodes(standbyNodeList)
}

if (standbyRemove.length > 0) {
Expand Down
22 changes: 10 additions & 12 deletions src/NodeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,6 @@ export function addNodes(status: NodeStatus, nodes: Node[]): 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)) standbyList.set(key, node)
break
}
/* eslint-disable security/detect-object-injection */
byPublicKey[node.publicKey] = node
Expand All @@ -172,7 +164,7 @@ export function addNodes(status: NodeStatus, nodes: Node[]): void {
}
}
}
export function refreshNodes(status: NodeStatus, nodes: Node[]): void {
export function refreshNodes(status: NodeStatus, nodes: ConsensusNodeInfo[] | JoinedConsensor[]): void {
if (nodes.length === 0) return
Logger.mainLogger.debug('Refreshing nodes', nodes.length, nodes)
for (const node of nodes) {
Expand All @@ -184,9 +176,6 @@ export function refreshNodes(status: NodeStatus, nodes: Node[]): void {
Logger.mainLogger.debug('adding new node during refresh', node.publicKey)
list.push(node)
switch (status) {
case NodeStatus.STANDBY:
standbyList.set(node.publicKey, node)
break
case NodeStatus.SYNCING:
syncingList.set(node.publicKey, node)
break
Expand Down Expand Up @@ -254,6 +243,15 @@ export function removeNodes(publicKeys: string[]): void {
}
}

export const addStandbyNodes = (nodes: ConsensusNodeInfo[]): void => {
if (nodes.length === 0) return
Logger.mainLogger.debug('Adding standby nodes to the list', nodes.length, nodes)
for (const node of nodes) {
if (standbyList.has(node.publicKey)) continue
standbyList.set(node.publicKey, node)
}
}

export const removeStandbyNodes = (publicKeys: string[]): void => {
if (publicKeys.length > 0) Logger.mainLogger.debug('Removing standby nodes', publicKeys)
for (const key of publicKeys) {
Expand Down
8 changes: 3 additions & 5 deletions src/sync-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { ArchiverNodeInfo, resetActiveArchivers } from '../State'
import { getActiveNodeListFromArchiver } from '../NodeList'
import * as NodeList from '../NodeList'
import { verifyArchiverList, verifyCycleRecord, verifyStandbyList, verifyValidatorList } from './verify'
import { verifyArchiverList, verifyCycleRecord, verifyValidatorList } from './verify'
import * as Logger from '../Logger'

/**
Expand Down Expand Up @@ -112,7 +112,7 @@ export function syncV2(
}))
NodeList.addNodes(NodeList.NodeStatus.SYNCING, syncingNodeList)
NodeList.addNodes(NodeList.NodeStatus.ACTIVE, activeNodeList)
NodeList.addNodes(NodeList.NodeStatus.STANDBY, standbyNodeList)
NodeList.addStandbyNodes(standbyNodeList)

// reset the active archivers list with the new list
resetActiveArchivers(archiverList)
Expand Down Expand Up @@ -172,9 +172,7 @@ function syncStandbyNodeList(
return robustQueryForStandbyNodeListHash(activeNodes).andThen(({ value, winningNodes }) =>
// get full standby list from one of the winning nodes
getStandbyNodeListFromNode(winningNodes[0], value.standbyNodeListHash).andThen((standbyList) =>
verifyStandbyList(standbyList, value.standbyNodeListHash).map(
() => [standbyList, value.standbyNodeListHash] as [P2PTypes.JoinTypes.JoinRequest[], hexstring]
)
okAsync([standbyList, value.standbyNodeListHash] as [P2PTypes.JoinTypes.JoinRequest[], hexstring])
)
)
}
Expand Down

0 comments on commit a21029b

Please sign in to comment.