mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-07-31 15:01:58 +00:00
feat: Add getRelayPeerId
method for IFluenceClient
(#260)
This commit is contained in:
@@ -36,6 +36,9 @@ export const main = async () => {
|
|||||||
|
|
||||||
console.log('connected');
|
console.log('connected');
|
||||||
|
|
||||||
|
const relayPeerId = (await Fluence.getClient()).getRelayPeerId();
|
||||||
|
console.log('relay:', relayPeerId);
|
||||||
|
|
||||||
await registerHelloWorld({
|
await registerHelloWorld({
|
||||||
hello(str) {
|
hello(str) {
|
||||||
return 'Hello, ' + str + '!';
|
return 'Hello, ' + str + '!';
|
||||||
|
@@ -141,15 +141,20 @@ export interface IFluenceClient {
|
|||||||
onConnectionStateChange(handler: (state: ConnectionState) => void): ConnectionState;
|
onConnectionStateChange(handler: (state: ConnectionState) => void): ConnectionState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return peers secret key as byte array.
|
* Return peer's secret key as byte array.
|
||||||
*/
|
*/
|
||||||
getPeerSecretKey(): Uint8Array;
|
getPeerSecretKey(): Uint8Array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return peers public key as a base58 string (multihash/CIDv0).
|
* Return peer's public key as a base58 string (multihash/CIDv0).
|
||||||
*/
|
*/
|
||||||
getPeerId(): string;
|
getPeerId(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return relay's public key as a base58 string (multihash/CIDv0).
|
||||||
|
*/
|
||||||
|
getRelayPeerId(): string;
|
||||||
|
|
||||||
// TODO: come up with a working interface for
|
// TODO: come up with a working interface for
|
||||||
// - particle creation
|
// - particle creation
|
||||||
// - particle initialization
|
// - particle initialization
|
||||||
|
@@ -142,6 +142,10 @@ export class FluencePeer implements IFluenceClient {
|
|||||||
return this.getStatus().peerId!;
|
return this.getStatus().peerId!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRelayPeerId(): string {
|
||||||
|
return this.getStatus().relayPeerId!;
|
||||||
|
}
|
||||||
|
|
||||||
getPeerSecretKey(): Uint8Array {
|
getPeerSecretKey(): Uint8Array {
|
||||||
if (!this._keyPair) {
|
if (!this._keyPair) {
|
||||||
throw new Error("Can't get key pair: peer is not initialized");
|
throw new Error("Can't get key pair: peer is not initialized");
|
||||||
|
Reference in New Issue
Block a user