mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-07-19 14:35:42 +00:00
Pin Polkadot CC1 ahead of Kusama (#265)
This commit is contained in:
@@ -4,7 +4,7 @@ import { AllChains, Chains, Chain, Ago, OfflineIndicator } from './components';
|
|||||||
import { Row, Column } from './components/List';
|
import { Row, Column } from './components/List';
|
||||||
import { Connection } from './Connection';
|
import { Connection } from './Connection';
|
||||||
import { Persistent, PersistentObject, PersistentSet } from './persist';
|
import { Persistent, PersistentObject, PersistentSet } from './persist';
|
||||||
import { State, Node, ChainData, PINNED_CHAIN } from './state';
|
import { State, Node, ChainData, comparePinnedChains } from './state';
|
||||||
import { getHashData } from './utils';
|
import { getHashData } from './utils';
|
||||||
import stable from 'stable';
|
import stable from 'stable';
|
||||||
|
|
||||||
@@ -203,12 +203,10 @@ export default class App extends React.Component<{}, State> {
|
|||||||
this.chainsCache = stable.inplace(
|
this.chainsCache = stable.inplace(
|
||||||
Array.from(this.state.chains.values()),
|
Array.from(this.state.chains.values()),
|
||||||
(a, b) => {
|
(a, b) => {
|
||||||
if (a.label === PINNED_CHAIN) {
|
const pinned = comparePinnedChains(a.label, b.label);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.label === PINNED_CHAIN) {
|
if (pinned !== 0) {
|
||||||
return 1;
|
return pinned;
|
||||||
}
|
}
|
||||||
|
|
||||||
return b.nodeCount - a.nodeCount;
|
return b.nodeCount - a.nodeCount;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
Node,
|
Node,
|
||||||
UpdateBound,
|
UpdateBound,
|
||||||
ChainData,
|
ChainData,
|
||||||
PINNED_CHAIN,
|
PINNED_CHAINS,
|
||||||
} from './state';
|
} from './state';
|
||||||
import { PersistentSet } from './persist';
|
import { PersistentSet } from './persist';
|
||||||
import { getHashData, setHashData } from './utils';
|
import { getHashData, setHashData } from './utils';
|
||||||
@@ -518,7 +518,7 @@ export class Connection {
|
|||||||
let topChain: Maybe<ChainData> = null;
|
let topChain: Maybe<ChainData> = null;
|
||||||
|
|
||||||
for (const chain of chains.values()) {
|
for (const chain of chains.values()) {
|
||||||
if (chain.label === PINNED_CHAIN) {
|
if (PINNED_CHAINS[chain.label] === 1) {
|
||||||
topChain = chain;
|
topChain = chain;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -1,7 +1,17 @@
|
|||||||
import { Types, Maybe, SortedCollection } from './common';
|
import { Types, Maybe, SortedCollection } from './common';
|
||||||
import { Column } from './components/List';
|
import { Column } from './components/List';
|
||||||
|
|
||||||
export const PINNED_CHAIN = 'Kusama';
|
export const PINNED_CHAINS = {
|
||||||
|
Kusama: 2,
|
||||||
|
'Polkadot CC1': 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function comparePinnedChains(a: string, b: string) {
|
||||||
|
const aWeight = PINNED_CHAINS[a] || 1024;
|
||||||
|
const bWeight = PINNED_CHAINS[b] || 1024;
|
||||||
|
|
||||||
|
return aWeight - bWeight;
|
||||||
|
}
|
||||||
|
|
||||||
export class Node {
|
export class Node {
|
||||||
public static compare(a: Node, b: Node): number {
|
public static compare(a: Node, b: Node): number {
|
||||||
|
|||||||
Reference in New Issue
Block a user