Subscribe to chains by genesis hash (#395)

* Handle subscription by hash in the frontend

* Forward-ported backend changes

* Fix unit tests

* Remove unused `chains_by_label`

* fmt

* Updated but failing E2E tests

* subscribe by genesis hash in tests

* fmt

* Copy `BlockHash` instead of returning a ref

* Pin chains by genesisHash

Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
Maciej Hirsz
2021-09-02 17:54:19 +02:00
committed by GitHub
parent ec5db0fbbf
commit a4069e4b3d
16 changed files with 156 additions and 140 deletions
+7 -4
View File
@@ -19,8 +19,10 @@ import { Types, Maybe, SortedCollection } from './common';
import { Column } from './components/List';
export const PINNED_CHAINS = {
Kusama: 2,
Polkadot: 1,
// Kusama
'0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe': 2,
// Polkadot
'0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3': 1,
};
export function comparePinnedChains(a: string, b: string) {
@@ -275,8 +277,8 @@ export interface State {
blockTimestamp: Types.Timestamp;
blockAverage: Maybe<Types.Milliseconds>;
timeDiff: Types.Milliseconds;
subscribed: Maybe<Types.ChainLabel>;
chains: Map<Types.ChainLabel, ChainData>;
subscribed: Maybe<Types.GenesisHash>;
chains: Map<Types.GenesisHash, ChainData>;
nodes: SortedCollection<Node>;
settings: Readonly<State.Settings>;
pins: Readonly<Set<Types.NodeName>>;
@@ -290,5 +292,6 @@ export type Update = <K extends keyof State>(
export interface ChainData {
label: Types.ChainLabel;
genesisHash: Types.GenesisHash;
nodeCount: Types.NodeCount;
}