*Update dist
This commit is contained in:
parent
cc5c988ce7
commit
f7a8b69a55
|
@ -1,30 +1,35 @@
|
|||
import RpcQuery from "./rpcQuery.js";
|
||||
export default class RpcNetwork {
|
||||
constructor(dht?: any);
|
||||
private _dht;
|
||||
get dht(): any;
|
||||
private _majorityThreshold;
|
||||
get majorityThreshold(): number;
|
||||
set majorityThreshold(value: number);
|
||||
private _maxTtl;
|
||||
get maxTtl(): number;
|
||||
set maxTtl(value: number);
|
||||
private _queryTimeout;
|
||||
get queryTimeout(): number;
|
||||
set queryTimeout(value: number);
|
||||
private _relayTimeout;
|
||||
get relayTimeout(): number;
|
||||
set relayTimeout(value: number);
|
||||
private _relays;
|
||||
get relays(): string[];
|
||||
private _ready?;
|
||||
get ready(): Promise<void>;
|
||||
private _force;
|
||||
get force(): boolean;
|
||||
set force(value: boolean);
|
||||
addRelay(pubkey: string): void;
|
||||
removeRelay(pubkey: string): boolean;
|
||||
clearRelays(): void;
|
||||
query(query: string, chain: string, data?: object | any[], force?: boolean): RpcQuery;
|
||||
constructor(dht?: any);
|
||||
private _dht;
|
||||
get dht(): any;
|
||||
private _majorityThreshold;
|
||||
get majorityThreshold(): number;
|
||||
set majorityThreshold(value: number);
|
||||
private _maxTtl;
|
||||
get maxTtl(): number;
|
||||
set maxTtl(value: number);
|
||||
private _queryTimeout;
|
||||
get queryTimeout(): number;
|
||||
set queryTimeout(value: number);
|
||||
private _relayTimeout;
|
||||
get relayTimeout(): number;
|
||||
set relayTimeout(value: number);
|
||||
private _relays;
|
||||
get relays(): string[];
|
||||
private _ready?;
|
||||
get ready(): Promise<void>;
|
||||
private _bypassCache;
|
||||
get bypassCache(): boolean;
|
||||
set bypassCache(value: boolean);
|
||||
addRelay(pubkey: string): void;
|
||||
removeRelay(pubkey: string): boolean;
|
||||
clearRelays(): void;
|
||||
query(
|
||||
query: string,
|
||||
chain: string,
|
||||
data?: object | any[],
|
||||
bypassCache?: boolean
|
||||
): RpcQuery;
|
||||
}
|
||||
//# sourceM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IAAI,GAAE,MAAM,GAAG,GAAG,EAAO,EACzB,WAAW,GAAE,OAAe,GAC3B,QAAQ;CAQZ"}
|
|
@ -48,12 +48,12 @@ export default class RpcNetwork {
|
|||
}
|
||||
return this._ready;
|
||||
}
|
||||
_force = false;
|
||||
get force() {
|
||||
return this._force;
|
||||
_bypassCache = false;
|
||||
get bypassCache() {
|
||||
return this._bypassCache;
|
||||
}
|
||||
set force(value) {
|
||||
this._force = value;
|
||||
set bypassCache(value) {
|
||||
this._bypassCache = value;
|
||||
}
|
||||
addRelay(pubkey) {
|
||||
this._relays.push(pubkey);
|
||||
|
@ -70,12 +70,12 @@ export default class RpcNetwork {
|
|||
clearRelays() {
|
||||
this._relays = [];
|
||||
}
|
||||
query(query, chain, data = {}, force = false) {
|
||||
query(query, chain, data = {}, bypassCache = false) {
|
||||
return new RpcQuery(this, {
|
||||
query,
|
||||
chain,
|
||||
data,
|
||||
force: force || this._force,
|
||||
bypassCache: bypassCache || this._bypassCache,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
import RpcNetwork from "./rpcNetwork.js";
|
||||
import { RPCRequest } from "./types";
|
||||
import { RPCRequest } from "./types.js";
|
||||
export default class RpcQuery {
|
||||
private _network;
|
||||
private _query;
|
||||
private _promise?;
|
||||
private _timeoutTimer?;
|
||||
private _timeout;
|
||||
private _completed;
|
||||
private _responses;
|
||||
private _promiseResolve?;
|
||||
private _maxTries;
|
||||
private _tries;
|
||||
constructor(network: RpcNetwork, query: RPCRequest);
|
||||
get result(): Promise<any>;
|
||||
private handeTimeout;
|
||||
private resolve;
|
||||
private init;
|
||||
private queryRelay;
|
||||
private checkResponses;
|
||||
private retry;
|
||||
private _network;
|
||||
private _query;
|
||||
private _promise?;
|
||||
private _timeoutTimer?;
|
||||
private _timeout;
|
||||
private _completed;
|
||||
private _responses;
|
||||
private _promiseResolve?;
|
||||
private _maxTries;
|
||||
private _tries;
|
||||
constructor(network: RpcNetwork, query: RPCRequest);
|
||||
get result(): Promise<any>;
|
||||
private handeTimeout;
|
||||
private resolve;
|
||||
private init;
|
||||
private queryRelay;
|
||||
private checkResponses;
|
||||
private retry;
|
||||
}
|
||||
//# 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) => {
|
||||
let timer;
|
||||
socket.on("data", (res) => {
|
||||
clearTimeout(timer);
|
||||
if (timer && timer.close) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
socket.end();
|
||||
const response = unpack(res);
|
||||
if (response && response.error) {
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
export interface RPCRequest {
|
||||
force: boolean;
|
||||
chain: string;
|
||||
query: string;
|
||||
data: any;
|
||||
bypassCache: boolean;
|
||||
chain: string;
|
||||
query: string;
|
||||
data: any;
|
||||
}
|
||||
export interface RPCResponse {
|
||||
updated: number;
|
||||
data: any | {
|
||||
error: string | boolean;
|
||||
};
|
||||
updated: number;
|
||||
data: any;
|
||||
error?: string;
|
||||
}
|
||||
//# 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