Skip to content

Commit 66dbc08

Browse files
unify locations
1 parent 532387c commit 66dbc08

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

explorer/src/App.tsx

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,10 @@ import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
33
import { LatLng, DivIcon } from "leaflet";
44
import "leaflet/dist/leaflet.css";
55
import init, { parse_seed, parse_notarized, parse_finalized } from "./alto_types/alto_types.js";
6-
import { WS_URL, PUBLIC_KEY } from "./config";
6+
import { WS_URL, PUBLIC_KEY, LOCATIONS } from "./config";
77
import { SeedJs, NotarizedJs, FinalizedJs, BlockJs } from "./types";
88
import "./App.css";
99

10-
// Array of locations for deterministic mapping
11-
const locations: [number, number][] = [
12-
[37.7749, -122.4194], // San Francisco
13-
[51.5074, -0.1278], // London
14-
[35.6895, 139.6917], // Tokyo
15-
[-33.8688, 151.2093], // Sydney
16-
[55.7558, 37.6173], // Moscow
17-
[-23.5505, -46.6333], // Sao Paulo
18-
[28.6139, 77.2090], // New Delhi
19-
[40.7128, -74.0060], // New York
20-
[19.4326, -99.1332], // Mexico City
21-
[31.2304, 121.4737], // Shanghai
22-
];
23-
24-
// Location names for popups
25-
const locationNames: string[] = [
26-
"San Francisco", "London", "Tokyo", "Sydney", "Moscow",
27-
"Sao Paulo", "New Delhi", "New York", "Mexico City", "Shanghai"
28-
];
29-
3010
type ViewStatus = "growing" | "notarized" | "finalized" | "timed_out";
3111

3212
interface ViewData {
@@ -220,7 +200,7 @@ const App: React.FC = () => {
220200

221201
// Add any missed views as skipped/timed out
222202
for (let missedView = startViewIndex; missedView < view; missedView++) {
223-
const locationIndex = missedView % locations.length;
203+
const locationIndex = missedView % LOCATIONS.length;
224204

225205
// Check if this view already exists
226206
const existingIndex = newViews.findIndex(v => v.view === missedView);
@@ -229,8 +209,8 @@ const App: React.FC = () => {
229209
// Only add if it doesn't already exist
230210
newViews.unshift({
231211
view: missedView,
232-
location: locations[locationIndex],
233-
locationName: locationNames[locationIndex],
212+
location: LOCATIONS[locationIndex][0],
213+
locationName: LOCATIONS[locationIndex][1],
234214
status: "timed_out",
235215
startTime: Date.now(),
236216
});
@@ -255,11 +235,11 @@ const App: React.FC = () => {
255235
}
256236

257237
// Create the new view data
258-
const locationIndex = view % locations.length;
238+
const locationIndex = view % LOCATIONS.length;
259239
const newView: ViewData = {
260240
view,
261-
location: locations[locationIndex],
262-
locationName: locationNames[locationIndex],
241+
location: LOCATIONS[locationIndex][0],
242+
locationName: LOCATIONS[locationIndex][1],
263243
status: "growing",
264244
startTime: Date.now(),
265245
signature: seed.signature,
@@ -336,11 +316,11 @@ const App: React.FC = () => {
336316
}
337317

338318
// If view doesn't exist, create it
339-
const locationIndex = view % locations.length;
319+
const locationIndex = view % LOCATIONS.length;
340320
return [{
341321
view,
342-
location: locations[locationIndex],
343-
locationName: locationNames[locationIndex],
322+
location: LOCATIONS[locationIndex][0],
323+
locationName: LOCATIONS[locationIndex][1],
344324
status: "notarized",
345325
startTime: Date.now(),
346326
notarizationTime: Date.now(),
@@ -381,11 +361,11 @@ const App: React.FC = () => {
381361
}
382362

383363
// If view doesn't exist, create it
384-
const locationIndex = view % locations.length;
364+
const locationIndex = view % LOCATIONS.length;
385365
return [{
386366
view,
387-
location: locations[locationIndex],
388-
locationName: locationNames[locationIndex],
367+
location: LOCATIONS[locationIndex][0],
368+
locationName: LOCATIONS[locationIndex][1],
389369
status: "finalized",
390370
startTime: Date.now(),
391371
finalizationTime: Date.now(),

explorer/src/config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
// TODO: Replace this with the indexer URL
12
export const INDEXER_URL = "http://localhost:4000";
23
export const WS_URL = "ws://localhost:4000/consensus/ws";
4+
5+
// TODO: Replace this with the consensus threshold key
36
export const PUBLIC_KEY_HEX = "976ab7efaef8a73690b9067690ac7541bc34f74b2543e8db16b5bf63aec487758ca98efdf5c9fcf1154941d8a8a1ec3d";
47

8+
// TODO: Replace this with an ordered list of validator locations (sorted by validator public key)
9+
export const LOCATIONS: [[number, number], string][] = [
10+
[[37.7749, -122.4194], "San Francisco"],
11+
[[51.5074, -0.1278], "London"],
12+
[[35.6895, 139.6917], "Tokyo"],
13+
[[-33.8688, 151.2093], "Sydney"],
14+
[[55.7558, 37.6173], "Moscow"],
15+
[[-23.5505, -46.6333], "Sao Paulo"],
16+
[[28.6139, 77.2090], "New Delhi"],
17+
[[40.7128, -74.0060], "New York"],
18+
[[19.4326, -99.1332], "Mexico City"],
19+
[[31.2304, 121.4737], "Shanghai"],
20+
];
21+
522
/**
623
* Converts a hexadecimal string to a Uint8Array.
724
* @param hex - The hexadecimal string to convert.

0 commit comments

Comments
 (0)