mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-12 15:51:00 +00:00
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:
@@ -119,7 +119,7 @@ export class Connection {
|
||||
// timestamp at which the last ping has been sent
|
||||
private pingSent: Maybe<Types.Timestamp> = null;
|
||||
// chain label to resubsribe to on reconnect
|
||||
private resubscribeTo: Maybe<Types.ChainLabel> = getHashData().chain;
|
||||
private resubscribeTo: Maybe<Types.GenesisHash> = getHashData().chain;
|
||||
// flag whether or not FE should subscribe to consensus updates on reconnect
|
||||
private resubscribeSendFinality: boolean = getHashData().tab === 'consensus';
|
||||
|
||||
@@ -132,7 +132,7 @@ export class Connection {
|
||||
this.bindSocket();
|
||||
}
|
||||
|
||||
public subscribe(chain: Types.ChainLabel) {
|
||||
public subscribe(chain: Types.GenesisHash) {
|
||||
if (
|
||||
this.appState.subscribed != null &&
|
||||
this.appState.subscribed !== chain
|
||||
@@ -148,7 +148,7 @@ export class Connection {
|
||||
this.socket.send(`subscribe:${chain}`);
|
||||
}
|
||||
|
||||
public subscribeConsensus(chain: Types.ChainLabel) {
|
||||
public subscribeConsensus(chain: Types.GenesisHash) {
|
||||
if (this.appState.authorities.length <= VIS_AUTHORITIES_LIMIT) {
|
||||
setHashData({ chain });
|
||||
this.resubscribeSendFinality = true;
|
||||
@@ -165,7 +165,7 @@ export class Connection {
|
||||
});
|
||||
}
|
||||
|
||||
public unsubscribeConsensus(chain: Types.ChainLabel) {
|
||||
public unsubscribeConsensus(chain: Types.GenesisHash) {
|
||||
this.resubscribeSendFinality = true;
|
||||
this.socket.send(`no-more-finality:${chain}`);
|
||||
}
|
||||
@@ -334,13 +334,13 @@ export class Connection {
|
||||
}
|
||||
|
||||
case ACTIONS.AddedChain: {
|
||||
const [label, nodeCount] = message.payload;
|
||||
const chain = chains.get(label);
|
||||
const [label, genesisHash, nodeCount] = message.payload;
|
||||
const chain = chains.get(genesisHash);
|
||||
|
||||
if (chain) {
|
||||
chain.nodeCount = nodeCount;
|
||||
} else {
|
||||
chains.set(label, { label, nodeCount });
|
||||
chains.set(genesisHash, { label, genesisHash, nodeCount });
|
||||
}
|
||||
|
||||
this.appUpdate({ chains });
|
||||
@@ -552,7 +552,7 @@ export class Connection {
|
||||
}
|
||||
|
||||
if (topChain) {
|
||||
this.subscribe(topChain.label);
|
||||
this.subscribe(topChain.genesisHash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user