*Update dist
This commit is contained in:
parent
cc5c988ce7
commit
f7a8b69a55
|
@ -1,30 +1,35 @@
|
||||||
import RpcQuery from "./rpcQuery.js";
|
import RpcQuery from "./rpcQuery.js";
|
||||||
export default class RpcNetwork {
|
export default class RpcNetwork {
|
||||||
constructor(dht?: any);
|
constructor(dht?: any);
|
||||||
private _dht;
|
private _dht;
|
||||||
get dht(): any;
|
get dht(): any;
|
||||||
private _majorityThreshold;
|
private _majorityThreshold;
|
||||||
get majorityThreshold(): number;
|
get majorityThreshold(): number;
|
||||||
set majorityThreshold(value: number);
|
set majorityThreshold(value: number);
|
||||||
private _maxTtl;
|
private _maxTtl;
|
||||||
get maxTtl(): number;
|
get maxTtl(): number;
|
||||||
set maxTtl(value: number);
|
set maxTtl(value: number);
|
||||||
private _queryTimeout;
|
private _queryTimeout;
|
||||||
get queryTimeout(): number;
|
get queryTimeout(): number;
|
||||||
set queryTimeout(value: number);
|
set queryTimeout(value: number);
|
||||||
private _relayTimeout;
|
private _relayTimeout;
|
||||||
get relayTimeout(): number;
|
get relayTimeout(): number;
|
||||||
set relayTimeout(value: number);
|
set relayTimeout(value: number);
|
||||||
private _relays;
|
private _relays;
|
||||||
get relays(): string[];
|
get relays(): string[];
|
||||||
private _ready?;
|
private _ready?;
|
||||||
get ready(): Promise<void>;
|
get ready(): Promise<void>;
|
||||||
private _force;
|
private _bypassCache;
|
||||||
get force(): boolean;
|
get bypassCache(): boolean;
|
||||||
set force(value: boolean);
|
set bypassCache(value: boolean);
|
||||||
addRelay(pubkey: string): void;
|
addRelay(pubkey: string): void;
|
||||||
removeRelay(pubkey: string): boolean;
|
removeRelay(pubkey: string): boolean;
|
||||||
clearRelays(): void;
|
clearRelays(): void;
|
||||||
query(query: string, chain: string, data?: object | any[], force?: boolean): RpcQuery;
|
query(
|
||||||
|
query: string,
|
||||||
|
chain: string,
|
||||||
|
data?: object | any[],
|
||||||
|
bypassCache?: boolean
|
||||||
|
): RpcQuery;
|
||||||
}
|
}
|
||||||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EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,MAAM,GAAG,GAAG,EAAO,EACzB,WAAW,GAAE,OAAe,GAC3B,QAAQ;CAQZ"}
|
|
@ -48,12 +48,12 @@ export default class RpcNetwork {
|
||||||
}
|
}
|
||||||
return this._ready;
|
return this._ready;
|
||||||
}
|
}
|
||||||
_force = false;
|
_bypassCache = false;
|
||||||
get force() {
|
get bypassCache() {
|
||||||
return this._force;
|
return this._bypassCache;
|
||||||
}
|
}
|
||||||
set force(value) {
|
set bypassCache(value) {
|
||||||
this._force = value;
|
this._bypassCache = value;
|
||||||
}
|
}
|
||||||
addRelay(pubkey) {
|
addRelay(pubkey) {
|
||||||
this._relays.push(pubkey);
|
this._relays.push(pubkey);
|
||||||
|
@ -70,12 +70,12 @@ export default class RpcNetwork {
|
||||||
clearRelays() {
|
clearRelays() {
|
||||||
this._relays = [];
|
this._relays = [];
|
||||||
}
|
}
|
||||||
query(query, chain, data = {}, force = false) {
|
query(query, chain, data = {}, bypassCache = false) {
|
||||||
return new RpcQuery(this, {
|
return new RpcQuery(this, {
|
||||||
query,
|
query,
|
||||||
chain,
|
chain,
|
||||||
data,
|
data,
|
||||||
force: force || this._force,
|
bypassCache: bypassCache || this._bypassCache,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import RpcNetwork from "./rpcNetwork.js";
|
import RpcNetwork from "./rpcNetwork.js";
|
||||||
import { RPCRequest } from "./types";
|
import { RPCRequest } from "./types.js";
|
||||||
export default class RpcQuery {
|
export default class RpcQuery {
|
||||||
private _network;
|
private _network;
|
||||||
private _query;
|
private _query;
|
||||||
private _promise?;
|
private _promise?;
|
||||||
private _timeoutTimer?;
|
private _timeoutTimer?;
|
||||||
private _timeout;
|
private _timeout;
|
||||||
private _completed;
|
private _completed;
|
||||||
private _responses;
|
private _responses;
|
||||||
private _promiseResolve?;
|
private _promiseResolve?;
|
||||||
private _maxTries;
|
private _maxTries;
|
||||||
private _tries;
|
private _tries;
|
||||||
constructor(network: RpcNetwork, query: RPCRequest);
|
constructor(network: RpcNetwork, query: RPCRequest);
|
||||||
get result(): Promise<any>;
|
get result(): Promise<any>;
|
||||||
private handeTimeout;
|
private handeTimeout;
|
||||||
private resolve;
|
private resolve;
|
||||||
private init;
|
private init;
|
||||||
private queryRelay;
|
private queryRelay;
|
||||||
private checkResponses;
|
private checkResponses;
|
||||||
private retry;
|
private retry;
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=rpcQuery.d.ts.map
|
//# sourceMappingURL=rpcQuery.d.ts.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"rpcQuery.d.ts","sourceRoot":"","sources":["../src/rpcQuery.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAe,MAAM,SAAS,CAAC;AAKlD,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAe;IAChC,OAAO,CAAC,aAAa,CAAC,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,UAAU,CAAwC;IAC1D,OAAO,CAAC,eAAe,CAAC,CAAsB;IAC9C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,MAAM,CAAK;gBAEP,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAMlD,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzB;IAED,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,OAAO;YAQD,IAAI;YA2BJ,UAAU;IAgCxB,OAAO,CAAC,cAAc;IAqDtB,OAAO,CAAC,KAAK;CASd"}
|
{"version":3,"file":"rpcQuery.d.ts","sourceRoot":"","sources":["../src/rpcQuery.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAe,MAAM,YAAY,CAAC;AAKrD,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAe;IAChC,OAAO,CAAC,aAAa,CAAC,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,UAAU,CAAwC;IAC1D,OAAO,CAAC,eAAe,CAAC,CAAsB;IAC9C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,MAAM,CAAK;gBAEP,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAMlD,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzB;IAED,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,OAAO;YAQD,IAAI;YA2BJ,UAAU;IAkCxB,OAAO,CAAC,cAAc;IAqDtB,OAAO,CAAC,KAAK;CASd"}
|
|
@ -64,7 +64,9 @@ export default class RpcQuery {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let timer;
|
let timer;
|
||||||
socket.on("data", (res) => {
|
socket.on("data", (res) => {
|
||||||
clearTimeout(timer);
|
if (timer && timer.close) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
socket.end();
|
socket.end();
|
||||||
const response = unpack(res);
|
const response = unpack(res);
|
||||||
if (response && response.error) {
|
if (response && response.error) {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
export interface RPCRequest {
|
export interface RPCRequest {
|
||||||
force: boolean;
|
bypassCache: boolean;
|
||||||
chain: string;
|
chain: string;
|
||||||
query: string;
|
query: string;
|
||||||
data: any;
|
data: any;
|
||||||
}
|
}
|
||||||
export interface RPCResponse {
|
export interface RPCResponse {
|
||||||
updated: number;
|
updated: number;
|
||||||
data: any | {
|
data: any;
|
||||||
error: string | boolean;
|
error?: string;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=types.d.ts.map
|
//# sourceMappingURL=types.d.ts.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EACA,GAAG,GACH;QACE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,CAAC;CACP"}
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
Loading…
Reference in New Issue