Skip to content

Commit 14e897d

Browse files
committed
Cleanup remaining todos and unused code
1 parent cf0069d commit 14e897d

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

ui/src/components/Sim/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export interface ITransactionSent {
8484
recipient: string;
8585
}
8686

87-
8887
export interface IRankingBlockGenerated {
8988
type: EServerMessageType.RBGenerated;
9089
id: string;
@@ -133,7 +132,6 @@ export interface ITransaction {
133132
id: string;
134133
}
135134

136-
137135
export interface IEndorserBlock {
138136
id: string;
139137
}
@@ -198,7 +196,6 @@ export type TServerMessageType =
198196
| ITransactionSent
199197
| IUnknown;
200198

201-
// TODO: should rename ServerMessage -> ServerMessage
202199
export interface IServerMessage<T = TServerMessageType> {
203200
time_s: number;
204201
message: T;

ui/src/contexts/SimContext/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from "./types";
88

99
export const defaultAggregatedData: ISimulationAggregatedDataState = {
10-
progress: 0,
1110
nodes: new Map(),
1211
global: {
1312
praosTxOnChain: 0,

ui/src/contexts/SimContext/types.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { IServerMessage, ITransformedNodeMap } from "@/components/Sim/types";
22
import { Dispatch, RefObject } from "react";
33

4-
// TODO: unused
5-
export enum ESpeedOptions {
6-
"1% Speed" = 0.01,
7-
"3% Speed" = 0.03,
8-
"10% Speed" = 0.1,
9-
}
10-
114
// Types of messages submitted between nodes
125
export enum EMessageType {
136
EB = "eb",
@@ -51,7 +44,6 @@ export interface IMessageAnimation {
5144
}
5245

5346
export interface ISimulationAggregatedDataState {
54-
progress: number; // TODO: unused
5547
nodes: Map<string, ISimulationAggregatedData>;
5648
global: ISimulationGlobalData;
5749
lastNodesUpdated: string[];

ui/src/utils/timelineAggregation.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,26 @@ export const computeAggregatedDataAtTime = (
132132
const messageBytes = new Map<EMessageType, Map<string, number>>();
133133

134134
// Helper functions for efficient byte storage/retrieval
135-
const setMessageBytes = (messageType: EMessageType, messageId: string, size: number) => {
135+
const setMessageBytes = (
136+
messageType: EMessageType,
137+
messageId: string,
138+
size: number,
139+
) => {
136140
if (!messageBytes.has(messageType)) {
137141
messageBytes.set(messageType, new Map());
138142
}
139143
messageBytes.get(messageType)!.set(messageId, size);
140144
};
141145

142-
const getMessageBytes = (messageType: EMessageType, messageId: string): number => {
146+
const getMessageBytes = (
147+
messageType: EMessageType,
148+
messageId: string,
149+
): number => {
143150
return messageBytes.get(messageType)?.get(messageId) || 0;
144151
};
145152

146153
// Initialize result structure
147154
const result: ISimulationAggregatedDataState = {
148-
progress: targetTime,
149155
nodes: nodeStats,
150156
global: {
151157
praosTxOnChain: 0,
@@ -182,7 +188,10 @@ export const computeAggregatedDataAtTime = (
182188
case EServerMessageType.TransactionGenerated: {
183189
const stats = nodeStats.get(message.publisher);
184190
if (stats) {
185-
stats.generated.set(EMessageType.TX, (stats.generated.get(EMessageType.TX) || 0) + 1);
191+
stats.generated.set(
192+
EMessageType.TX,
193+
(stats.generated.get(EMessageType.TX) || 0) + 1,
194+
);
186195
setMessageBytes(EMessageType.TX, message.id, message.size_bytes);
187196
}
188197
break;
@@ -231,13 +240,13 @@ export const computeAggregatedDataAtTime = (
231240
break;
232241
}
233242

234-
235-
236-
237243
case EServerMessageType.EBGenerated: {
238244
const stats = nodeStats.get(message.producer);
239245
if (stats) {
240-
stats.generated.set(EMessageType.EB, (stats.generated.get(EMessageType.EB) || 0) + 1);
246+
stats.generated.set(
247+
EMessageType.EB,
248+
(stats.generated.get(EMessageType.EB) || 0) + 1,
249+
);
241250
setMessageBytes(EMessageType.EB, message.id, message.size_bytes);
242251
}
243252

@@ -316,7 +325,10 @@ export const computeAggregatedDataAtTime = (
316325
case EServerMessageType.RBGenerated: {
317326
const stats = nodeStats.get(message.producer);
318327
if (stats) {
319-
stats.generated.set(EMessageType.RB, (stats.generated.get(EMessageType.RB) || 0) + 1);
328+
stats.generated.set(
329+
EMessageType.RB,
330+
(stats.generated.get(EMessageType.RB) || 0) + 1,
331+
);
320332
setMessageBytes(EMessageType.RB, message.id, message.size_bytes);
321333
}
322334

@@ -396,7 +408,10 @@ export const computeAggregatedDataAtTime = (
396408
case EServerMessageType.VTBundleGenerated: {
397409
const stats = nodeStats.get(message.producer);
398410
if (stats) {
399-
stats.generated.set(EMessageType.Votes, (stats.generated.get(EMessageType.Votes) || 0) + 1);
411+
stats.generated.set(
412+
EMessageType.Votes,
413+
(stats.generated.get(EMessageType.Votes) || 0) + 1,
414+
);
400415
setMessageBytes(EMessageType.Votes, message.id, message.size_bytes);
401416
}
402417
break;

0 commit comments

Comments
 (0)