make fork graph take less space

This commit is contained in:
Victor Oliva
2024-11-01 13:27:54 +01:00
parent d67c356b98
commit 2c28081bdf
3 changed files with 7 additions and 11 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ export const BlockPopover: FC<{ hash: string }> = ({ hash }) => {
<div>
<h3 className="font-bold text-lg">
Block{" "}
<span className="font-mono text-sm font-normal text-slate-200">
<span className="font-mono text-sm font-normal text-slate-300">
{hash}
</span>
</h3>
+5 -9
View File
@@ -31,10 +31,9 @@ const blockTable$ = state(
const blockPositions: Record<string, number> = {}
const positionsTaken = new Set<number>()
const lockFreePosition = () => {
const getFreePosition = () => {
for (let i = 0; ; i++) {
if (!positionsTaken.has(i)) {
positionsTaken.add(i)
return i
}
}
@@ -57,13 +56,10 @@ const blockTable$ = state(
)
}
}
const positionsMerged: number[] = []
competingBlocks.forEach((block) => {
const branches = [...positionsTaken].filter(
(v) => !positionsMerged.includes(v),
)
const branches = [...positionsTaken]
const position = blockPositions[block.hash] ?? lockFreePosition()
const position = blockPositions[block.hash] ?? getFreePosition()
if (blockPositions[block.parent] != null) {
// then it means the parent was already discovered by a previous
// so this is the start of a branch
@@ -73,10 +69,11 @@ const blockTable$ = state(
branches,
position,
})
positionsMerged.push(position)
positionsTaken.delete(position)
} else {
// We put our parent underneath us
blockPositions[block.parent] = position
positionsTaken.add(position)
result.push({
block,
branched: null,
@@ -85,7 +82,6 @@ const blockTable$ = state(
})
}
})
positionsMerged.forEach((v) => positionsTaken.delete(v))
}
return result
+1 -1
View File
@@ -142,7 +142,7 @@ interface EventEllipsis {
}
const eventKey = (evt: EventInfo | EventEllipsis) =>
`${evt?.number.toLocaleString()}-${evt?.extrinsicNumber}`
const MAX_GROUP_LENGTH = 6
const MAX_GROUP_LENGTH = 7
const recentEvents$ = state(
combineKeys(recordedBlocks$, (key) =>
blockInfo$(key).pipe(