Skip to content

Commit

Permalink
Add radix sync cycle info
Browse files Browse the repository at this point in the history
  • Loading branch information
urnotsam committed Jul 12, 2024
1 parent 539bc7e commit 210b54e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
20 changes: 16 additions & 4 deletions public/sync-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
sortAsc: true,
shouldRefresh: true,
hideEdgeOOS: false,
recentRuntimeSyncMap: new Map(),
}
},
async mounted() {
Expand All @@ -92,8 +93,11 @@
},
},
methods: {
getBorderStyle(cycleFinishedSyncing) {
const cyclesAgo = this.networkStatus.counter - cycleFinishedSyncing
getRadixSyncStyle(nodeId, radixId) {
const uniqueKey = `${nodeId}-${radixId}`
const recentRuntimeSyncCycle = this.recentRuntimeSyncMap.get(uniqueKey)
if (!recentRuntimeSyncCycle) return {}
const cyclesAgo = this.networkStatus.counter - recentRuntimeSyncCycle
let borderColor

if (cyclesAgo === 1) {
Expand All @@ -102,13 +106,13 @@
borderColor = this.borderColors.DARKGRAY
} else if (cyclesAgo === 3) {
borderColor = this.borderColors.GRAY
} else if (cyclesAgo === 4) {
} else if (cyclesAgo >= 4) {
borderColor = this.borderColors.LIGHTGRAY
} else {
borderColor = this.borderColors.OFFWHITE
}

return { border: `2px solid ${borderColor}` }
return { backgroundColor: borderColor }
},
getBackgroundColor(r) {
let colorKey = ''
Expand Down Expand Up @@ -181,6 +185,14 @@
const result = node.lastInSyncResult
this.networkStatus.counter = node.cycleCounter

for (let radix of result?.radixes || []) {
const recentRuntimeSyncCycle = radix.recentRuntimeSyncCycle || -1
const uniqueKey = `${nodeId}-${radix.radix}`
if (recentRuntimeSyncCycle !== -1) {
this.recentRuntimeSyncMap.set(uniqueKey, recentRuntimeSyncCycle)
}
}

this.nodeLoads.push({
id: nodeId,
ip: node.nodeIpInfo.externalIp,
Expand Down
35 changes: 21 additions & 14 deletions views/sync-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@
<span :style="getLegendColorStyle(borderColors.BLACK)" class="legend-span">1</span>
<span :style="getLegendColorStyle(borderColors.DARKGRAY)" class="legend-span">2</span>
<span :style="getLegendColorStyle(borderColors.GRAY)" class="legend-span">3</span>
<span :style="getLegendColorStyle(borderColors.LIGHTGRAY)" class="legend-span">4</span>
<span :style="getLegendColorStyle(borderColors.OFFWHITE)" class="legend-span">5</span>
<span :style="getLegendColorStyle(borderColors.LIGHTGRAY)" class="legend-span">4+</span>
</div> <span class="label">Border Colors (Synced Cycles Ago)</span>
</div>
</div>
Expand Down Expand Up @@ -171,18 +170,26 @@
<td>{{ node.cycleFinishedSyncing }}</td>
<td>{{ node.recentRuntimeSync }}</td>
<td>
<template v-for="r in node.radixes" :key="r.radix">
<span
:class="radixClass(r)"
:style="[getBorderStyle(node.cycleFinishedSyncing), { backgroundColor: getBackgroundColor(r) }]"
style="white-space: nowrap; display: inline-block; min-width: 25px; margin-right: 2px; margin-bottom: 4px; padding: 2px;"
>
<span :style="{ color: 'white' }">
{{ r.inConsensusRange && r.inEdgeRange ? "C/E" : (r.inConsensusRange ? "C" : (r.inEdgeRange ? "E" : "")) }}
</span>
<span :style="{ color: 'black' }">{{ r.radix }}</span>
</span>
</template>
<template>
<div>
<template v-for="r in node.radixes" :key="r.radix">
<div style="display: inline-block; margin-right: 2px; margin-bottom: 4px;">
<div
:style="[getRadixSyncStyle(node.id, r.radix), { height: '5px', width: '100%', marginBottom: '2px' }]"
></div>
<span
:class="radixClass(r)"
:style="{ backgroundColor: getBackgroundColor(r), whiteSpace: 'nowrap', display: 'inline-block', minWidth: '25px', padding: '2px' }"
>
<span :style="{ color: 'white' }">
{{ r.inConsensusRange && r.inEdgeRange ? "C/E" : (r.inConsensusRange ? "C" : (r.inEdgeRange ? "E" : "")) }}
</span>
<span :style="{ color: 'black' }">{{ r.radix }}</span>
</span>
</div>
</template>
</div>
</template>
</td>
</tr>
</tbody>
Expand Down

0 comments on commit 210b54e

Please sign in to comment.