Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete correct abortControllers #1184

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ build
node_modules

lib
dist
# dist
test/test-data/go-ipfs-repo/LOCK
test/test-data/go-ipfs-repo/LOG
test/test-data/go-ipfs-repo/LOG.old
Expand Down
55 changes: 55 additions & 0 deletions dist/index.min.js

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions dist/src/address-manager/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
export = AddressManager;
/**
* @typedef {Object} AddressManagerOptions
* @property {string[]} [listen = []] - list of multiaddrs string representation to listen.
* @property {string[]} [announce = []] - list of multiaddrs string representation to announce.
*/
/**
* @fires AddressManager#change:addresses Emitted when a addresses change.
*/
declare class AddressManager extends EventEmitter {
/**
* Responsible for managing the peer addresses.
* Peers can specify their listen and announce addresses.
* The listen addresses will be used by the libp2p transports to listen for new connections,
* while the announce addresses will be used for the peer addresses' to other peers in the network.
*
* @class
* @param {PeerId} peerId - The Peer ID of the node
* @param {object} [options]
* @param {Array<string>} [options.listen = []] - list of multiaddrs string representation to listen.
* @param {Array<string>} [options.announce = []] - list of multiaddrs string representation to announce.
*/
constructor(peerId: PeerId, { listen, announce }?: {
listen?: string[] | undefined;
announce?: string[] | undefined;
} | undefined);
peerId: PeerId;
listen: Set<string>;
announce: Set<string>;
observed: Set<any>;
/**
* Get peer listen multiaddrs.
*
* @returns {Multiaddr[]}
*/
getListenAddrs(): Multiaddr[];
/**
* Get peer announcing multiaddrs.
*
* @returns {Multiaddr[]}
*/
getAnnounceAddrs(): Multiaddr[];
/**
* Get observed multiaddrs.
*
* @returns {Array<Multiaddr>}
*/
getObservedAddrs(): Array<Multiaddr>;
/**
* Add peer observed addresses
*
* @param {string | Multiaddr} addr
*/
addObservedAddr(addr: string | Multiaddr): void;
}
declare namespace AddressManager {
export { AddressManagerOptions };
}
import { EventEmitter } from "events";
import PeerId = require("peer-id");
import { Multiaddr } from "multiaddr";
type AddressManagerOptions = {
/**
* - list of multiaddrs string representation to listen.
*/
listen?: string[] | undefined;
/**
* - list of multiaddrs string representation to announce.
*/
announce?: string[] | undefined;
};
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/src/address-manager/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions dist/src/circuit/auto-relay.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
export = AutoRelay;
/**
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
* @typedef {import('../peer-store/types').Address} Address
* @typedef {import('peer-id')} PeerId
*/
/**
* @typedef {Object} AutoRelayProperties
* @property {import('../')} libp2p
*
* @typedef {Object} AutoRelayOptions
* @property {number} [maxListeners = 1] - maximum number of relays to listen.
* @property {(error: Error, msg?: string) => {}} [onError]
*/
declare class AutoRelay {
/**
* Creates an instance of AutoRelay.
*
* @class
* @param {AutoRelayProperties & AutoRelayOptions} props
*/
constructor({ libp2p, maxListeners, onError }: AutoRelayProperties & AutoRelayOptions);
_libp2p: import("../");
_peerId: import("peer-id");
_peerStore: import("../peer-store/types").PeerStore;
_connectionManager: import("../connection-manager");
_transportManager: import("../transport-manager");
_addressSorter: (addresses: import("../peer-store/types").Address[]) => import("../peer-store/types").Address[];
maxListeners: number;
/**
* @type {Set<string>}
*/
_listenRelays: Set<string>;
/**
* Check if a peer supports the relay protocol.
* If the protocol is not supported, check if it was supported before and remove it as a listen relay.
* If the protocol is supported, check if the peer supports **HOP** and add it as a listener if
* inside the threshold.
*
* @param {Object} props
* @param {PeerId} props.peerId
* @param {string[]} props.protocols
* @returns {Promise<void>}
*/
_onProtocolChange({ peerId, protocols }: {
peerId: PeerId;
protocols: string[];
}): Promise<void>;
/**
* Peer disconnects.
*
* @param {Connection} connection - connection to the peer
*/
_onPeerDisconnected(connection: Connection): void;
/**
* @param {Error} error
* @param {string} [msg]
*/
_onError: (error: Error, msg?: string | undefined) => void;
/**
* Attempt to listen on the given relay connection.
*
* @private
* @param {Connection} connection - connection to the peer
* @param {string} id - peer identifier string
* @returns {Promise<void>}
*/
private _addListenRelay;
/**
* Remove listen relay.
*
* @private
* @param {string} id - peer identifier string.
*/
private _removeListenRelay;
/**
* Try to listen on available hop relay connections.
* The following order will happen while we do not have enough relays.
* 1. Check the metadata store for known relays, try to listen on the ones we are already connected.
* 2. Dial and try to listen on the peers we know that support hop but are not connected.
* 3. Search the network.
*
* @param {string[]} [peersToIgnore]
*/
_listenOnAvailableHopRelays(peersToIgnore?: string[] | undefined): Promise<void>;
/**
* @param {PeerId} peerId
*/
_tryToListenOnRelay(peerId: PeerId): Promise<void>;
}
declare namespace AutoRelay {
export { Connection, Address, PeerId, AutoRelayProperties, AutoRelayOptions };
}
type PeerId = import('peer-id');
type Connection = import("libp2p-interfaces/src/connection/connection");
type AutoRelayProperties = {
libp2p: import('../');
};
type AutoRelayOptions = {
/**
* - maximum number of relays to listen.
*/
maxListeners?: number | undefined;
onError?: ((error: Error, msg?: string | undefined) => {}) | undefined;
};
type Address = import('../peer-store/types').Address;
//# sourceMappingURL=auto-relay.d.ts.map
1 change: 1 addition & 0 deletions dist/src/circuit/auto-relay.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions dist/src/circuit/circuit/hop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
export type ICircuitRelay = import('../protocol').ICircuitRelay;
export type Connection = import("libp2p-interfaces/src/connection/connection");
export type MuxedStream = import('libp2p-interfaces/src/stream-muxer/types').MuxedStream;
export type Transport = import('../transport');
export type HopRequest = {
connection: Connection;
request: ICircuitRelay;
streamHandler: StreamHandler;
circuit: Transport;
};
/**
* @typedef {import('../protocol').ICircuitRelay} ICircuitRelay
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
* @typedef {import('../transport')} Transport
*/
/**
* @typedef {Object} HopRequest
* @property {Connection} connection
* @property {ICircuitRelay} request
* @property {StreamHandler} streamHandler
* @property {Transport} circuit
*/
/**
* @param {HopRequest} options
* @returns {Promise<void>}
*/
export function handleHop({ connection, request, streamHandler, circuit }: HopRequest): Promise<void>;
/**
* Performs a HOP request to a relay peer, to request a connection to another
* peer. A new, virtual, connection will be created between the two via the relay.
*
* @param {object} options
* @param {Connection} options.connection - Connection to the relay
* @param {ICircuitRelay} options.request
* @returns {Promise<MuxedStream>}
*/
export function hop({ connection, request }: {
connection: Connection;
request: ICircuitRelay;
}): Promise<MuxedStream>;
/**
* Performs a CAN_HOP request to a relay peer, in order to understand its capabilities.
*
* @param {object} options
* @param {Connection} options.connection - Connection to the relay
* @returns {Promise<boolean>}
*/
export function canHop({ connection }: {
connection: Connection;
}): Promise<boolean>;
/**
* Creates an unencoded CAN_HOP response based on the Circuits configuration
*
* @param {Object} options
* @param {Connection} options.connection
* @param {StreamHandler} options.streamHandler
* @param {Transport} options.circuit
* @private
*/
export function handleCanHop({ connection, streamHandler, circuit }: {
connection: Connection;
streamHandler: StreamHandler;
circuit: Transport;
}): void;
import StreamHandler = require("./stream-handler");
//# sourceMappingURL=hop.d.ts.map
1 change: 1 addition & 0 deletions dist/src/circuit/circuit/hop.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/src/circuit/circuit/stop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export function handleStop({ connection, request, streamHandler }: {
connection: Connection;
request: ICircuitRelay;
streamHandler: StreamHandler;
}): Promise<MuxedStream> | void;
export function stop({ connection, request }: {
connection: Connection;
request: ICircuitRelay;
}): Promise<MuxedStream | void>;
export type Connection = import("libp2p-interfaces/src/connection/connection");
export type MuxedStream = import('libp2p-interfaces/src/stream-muxer/types').MuxedStream;
export type ICircuitRelay = import('../protocol').ICircuitRelay;
import StreamHandler = require("./stream-handler");
//# sourceMappingURL=stop.d.ts.map
1 change: 1 addition & 0 deletions dist/src/circuit/circuit/stop.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions dist/src/circuit/circuit/stream-handler.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export = StreamHandler;
/**
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
* @typedef {import('../protocol').ICircuitRelay} ICircuitRelay
*/
declare class StreamHandler {
/**
* Create a stream handler for connection
*
* @class
* @param {object} options
* @param {MuxedStream} options.stream - A duplex iterable
* @param {number} [options.maxLength = 4096] - max bytes length of message
*/
constructor({ stream, maxLength }: {
stream: MuxedStream;
maxLength?: number | undefined;
});
stream: import("libp2p-interfaces/src/stream-muxer/types").MuxedStream;
shake: any;
decoder: AsyncGenerator<any, void, unknown>;
/**
* Read and decode message
*
* @async
*/
read(): Promise<CircuitRelay | undefined>;
/**
* Encode and write array of buffers
*
* @param {ICircuitRelay} msg - An unencoded CircuitRelay protobuf message
* @returns {void}
*/
write(msg: ICircuitRelay): void;
/**
* Return the handshake rest stream and invalidate handler
*
* @returns {*} A duplex iterable
*/
rest(): any;
/**
* @param {ICircuitRelay} msg - An unencoded CircuitRelay protobuf message
*/
end(msg: ICircuitRelay): void;
/**
* Close the stream
*
* @returns {void}
*/
close(): void;
}
declare namespace StreamHandler {
export { MuxedStream, ICircuitRelay };
}
import { CircuitRelay } from "../protocol";
type ICircuitRelay = import('../protocol').ICircuitRelay;
type MuxedStream = import('libp2p-interfaces/src/stream-muxer/types').MuxedStream;
//# sourceMappingURL=stream-handler.d.ts.map
1 change: 1 addition & 0 deletions dist/src/circuit/circuit/stream-handler.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/src/circuit/circuit/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type StreamHandler = import('./stream-handler');
export type ICircuitRelay = import('../protocol').ICircuitRelay;
/**
* Validate incomming HOP/STOP message
*
* @param {ICircuitRelay} msg - A CircuitRelay unencoded protobuf message
* @param {StreamHandler} streamHandler
*/
export function validateAddrs(msg: ICircuitRelay, streamHandler: StreamHandler): void;
//# sourceMappingURL=utils.d.ts.map
1 change: 1 addition & 0 deletions dist/src/circuit/circuit/utils.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions dist/src/circuit/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const ADVERTISE_BOOT_DELAY: number;
export const ADVERTISE_TTL: number;
export const CIRCUIT_PROTO_CODE: number;
export const HOP_METADATA_KEY: string;
export const HOP_METADATA_VALUE: string;
export const RELAY_RENDEZVOUS_NS: string;
//# sourceMappingURL=constants.d.ts.map
1 change: 1 addition & 0 deletions dist/src/circuit/constants.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading