Add option to print initiated particle ids (#147)

This commit is contained in:
Pavel
2022-04-06 15:16:45 +03:00
committed by GitHub
parent 41984b8912
commit c0e727bf8e
9 changed files with 94 additions and 71 deletions

View File

@ -101,6 +101,17 @@ export interface PeerConfig {
* Plugable AVM runner implementation. If not specified AvmBackgroundRunner will be used
*/
avmRunner?: AvmRunner;
/**
* Enables\disabled various debugging features
*/
debug?: {
/**
* If set to true, newly initiated particle ids will be printed to console.
* Useful to see what particle id is responsible for aqua function
*/
printParticleId?: boolean;
};
}
/**
@ -179,6 +190,10 @@ export class FluencePeer {
this._keyPair = await KeyPair.randomEd25519();
}
if (config?.debug?.printParticleId) {
this._printParticleId = true;
}
this._defaultTTL =
config?.defaultTtlMs !== undefined // don't miss value 0 (zero)
? config?.defaultTtlMs
@ -262,6 +277,10 @@ export class FluencePeer {
throw 'Cannot initiate new particle: peer is not initialized';
}
if (this._printParticleId) {
console.log('Particle id: ', particle.id);
}
if (particle.initPeerId === undefined) {
particle.initPeerId = this.getStatus().peerId;
}
@ -347,6 +366,7 @@ export class FluencePeer {
// Internal peer state
private _printParticleId: boolean = false;
private _defaultTTL: number;
private _relayPeerId: PeerIdB58 | null = null;
private _keyPair: KeyPair;