mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-11 17:41:10 +00:00
Process GRANDPA authority id (#179)
* Remove pubkey * Remove superfluous whitespace * Assign GRANDPA authority id as address
This commit is contained in:
committed by
Maciej Hirsz
parent
5b2c0ee37d
commit
98175772e4
@@ -37,12 +37,12 @@ export default class Node {
|
||||
public readonly chain: Types.ChainLabel;
|
||||
public readonly implementation: Types.NodeImplementation;
|
||||
public readonly version: Types.NodeVersion;
|
||||
public readonly address: Maybe<Types.Address>;
|
||||
public readonly networkId: Maybe<Types.NetworkId>;
|
||||
public readonly authority: boolean;
|
||||
|
||||
public readonly events = new EventEmitter() as EventEmitter & NodeEvents;
|
||||
|
||||
public address: Maybe<Types.Address> = null;
|
||||
public networkState: Maybe<Types.NetworkState> = null;
|
||||
public location: Maybe<Location> = null;
|
||||
public lastMessage: Types.Timestamp;
|
||||
@@ -81,7 +81,6 @@ export default class Node {
|
||||
config: string,
|
||||
implentation: Types.NodeImplementation,
|
||||
version: Types.NodeVersion,
|
||||
address: Maybe<Types.Address>,
|
||||
networkId: Maybe<Types.NetworkId>,
|
||||
authority: boolean,
|
||||
messages: Array<Message>,
|
||||
@@ -93,7 +92,6 @@ export default class Node {
|
||||
this.config = config;
|
||||
this.implementation = implentation;
|
||||
this.version = version;
|
||||
this.address = address;
|
||||
this.authority = authority;
|
||||
this.networkId = networkId;
|
||||
this.lastMessage = timestamp();
|
||||
@@ -141,9 +139,9 @@ export default class Node {
|
||||
if (message.msg === "system.connected") {
|
||||
cleanup();
|
||||
|
||||
const { name, chain, config, implementation, version, pubkey, authority, network_id: networkId } = message;
|
||||
const { name, chain, config, implementation, version, authority, network_id: networkId } = message;
|
||||
|
||||
resolve(new Node(ip, socket, name, chain, config, implementation, version, pubkey, networkId, authority === true, messages));
|
||||
resolve(new Node(ip, socket, name, chain, config, implementation, version, networkId, authority === true, messages));
|
||||
} else {
|
||||
if (messages.length === 10) {
|
||||
messages.shift();
|
||||
@@ -336,6 +334,7 @@ export default class Node {
|
||||
|
||||
private onAfgAuthoritySet(message: AfgAuthoritySet) {
|
||||
const {
|
||||
authority_id: authorityId,
|
||||
authority_set_id: authoritySetId,
|
||||
hash,
|
||||
number,
|
||||
@@ -345,6 +344,8 @@ export default class Node {
|
||||
// string by substrate before sending it.
|
||||
const authorities = JSON.parse(String(message.authorities)) as Types.Authorities;
|
||||
|
||||
this.address = authorityId;
|
||||
|
||||
if (JSON.stringify(this.authorities) !== String(message.authorities) ||
|
||||
this.authoritySetId !== authoritySetId) {
|
||||
const no = parseInt(String(number), 10) as Types.BlockNumber;
|
||||
|
||||
@@ -68,6 +68,7 @@ export interface AfgReceivedCommit extends AfgReceived {
|
||||
export interface AfgAuthoritySet {
|
||||
msg: 'afg.authority_set';
|
||||
ts: Date;
|
||||
authority_id: Types.Address,
|
||||
authorities: Types.Authorities;
|
||||
authority_set_id: Types.AuthoritySetId;
|
||||
number: Types.BlockNumber;
|
||||
@@ -81,7 +82,6 @@ export interface SystemConnected {
|
||||
config: string;
|
||||
implementation: Types.NodeImplementation;
|
||||
version: Types.NodeVersion;
|
||||
pubkey: Maybe<Types.Address>;
|
||||
authority: Maybe<boolean>;
|
||||
network_id: Maybe<Types.NetworkId>;
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ export class Connection {
|
||||
case Actions.AfgFinalized: {
|
||||
const [nodeAddress, finalizedNumber, finalizedHash] = message.payload;
|
||||
const no = parseInt(String(finalizedNumber), 10) as Types.BlockNumber;
|
||||
afg.receivedFinalized( nodeAddress, no, finalizedHash);
|
||||
afg.receivedFinalized(nodeAddress, no, finalizedHash);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user