@aztec/p2p 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +5 -7
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +2 -3
- package/dest/service/discV5_service.d.ts +5 -2
- package/dest/service/discV5_service.d.ts.map +1 -1
- package/dest/service/discV5_service.js +26 -9
- package/dest/service/dummy_service.d.ts +4 -1
- package/dest/service/dummy_service.d.ts.map +1 -1
- package/dest/service/dummy_service.js +7 -1
- package/dest/service/libp2p_service.d.ts +6 -14
- package/dest/service/libp2p_service.d.ts.map +1 -1
- package/dest/service/libp2p_service.js +49 -91
- package/dest/service/peer_manager.d.ts +25 -3
- package/dest/service/peer_manager.d.ts.map +1 -1
- package/dest/service/peer_manager.js +152 -12
- package/dest/service/service.d.ts +12 -6
- package/dest/service/service.d.ts.map +1 -1
- package/dest/service/service.js +1 -1
- package/dest/tx_pool/aztec_kv_tx_pool.d.ts +2 -1
- package/dest/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/tx_pool/aztec_kv_tx_pool.js +11 -6
- package/dest/tx_pool/instrumentation.d.ts +23 -0
- package/dest/tx_pool/instrumentation.d.ts.map +1 -0
- package/dest/tx_pool/instrumentation.js +48 -0
- package/dest/tx_pool/memory_tx_pool.d.ts +3 -1
- package/dest/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/tx_pool/memory_tx_pool.js +6 -2
- package/package.json +15 -6
- package/src/client/index.ts +4 -6
- package/src/client/p2p_client.ts +1 -2
- package/src/service/discV5_service.ts +28 -11
- package/src/service/dummy_service.ts +10 -1
- package/src/service/libp2p_service.ts +52 -101
- package/src/service/peer_manager.ts +187 -12
- package/src/service/service.ts +14 -7
- package/src/tx_pool/aztec_kv_tx_pool.ts +12 -3
- package/src/tx_pool/instrumentation.ts +58 -0
- package/src/tx_pool/memory_tx_pool.ts +8 -1
- package/dest/service/known_txs.d.ts +0 -31
- package/dest/service/known_txs.d.ts.map +0 -1
- package/dest/service/known_txs.js +0 -52
- package/src/service/known_txs.ts +0 -56
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type PeerId } from '@libp2p/interface';
|
|
2
|
-
/**
|
|
3
|
-
* Keeps a record of which Peers have 'seen' which transactions.
|
|
4
|
-
*/
|
|
5
|
-
export declare class KnownTxLookup {
|
|
6
|
-
private lookup;
|
|
7
|
-
constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Inform this lookup that a peer has 'seen' a transaction.
|
|
10
|
-
* @param peerId - The peerId of the peer that has 'seen' the transaction.
|
|
11
|
-
* @param txHash - The thHash of the 'seen' transaction.
|
|
12
|
-
*/
|
|
13
|
-
addPeerForTx(peerId: PeerId, txHash: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* Determine if a peer has 'seen' a transaction.
|
|
16
|
-
* @param peerId - The peerId of the peer.
|
|
17
|
-
* @param txHash - The thHash of the transaction.
|
|
18
|
-
* @returns A boolean indicating if the transaction has been 'seen' by the peer.
|
|
19
|
-
*/
|
|
20
|
-
hasPeerSeenTx(peerId: PeerId, txHash: string): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Updates the lookup from the result of settled txs
|
|
23
|
-
* These txs will be cleared out of the lookup.
|
|
24
|
-
* It is possible that some txs could still be gossiped for a
|
|
25
|
-
* short period of time meaning they come back into this lookup
|
|
26
|
-
* but this should be infrequent and cause no undesirable effects
|
|
27
|
-
* @param txHashes - The hashes of the newly settled transactions
|
|
28
|
-
*/
|
|
29
|
-
handleSettledTxs(txHashes: string[]): void;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=known_txs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"known_txs.d.ts","sourceRoot":"","sources":["../../src/service/known_txs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAqD;;IAInE;;;;OAIG;IACI,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAYlD;;;;;OAKG;IACI,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASnD;;;;;;;OAOG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE;CAK3C"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keeps a record of which Peers have 'seen' which transactions.
|
|
3
|
-
*/
|
|
4
|
-
export class KnownTxLookup {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.lookup = {};
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Inform this lookup that a peer has 'seen' a transaction.
|
|
10
|
-
* @param peerId - The peerId of the peer that has 'seen' the transaction.
|
|
11
|
-
* @param txHash - The thHash of the 'seen' transaction.
|
|
12
|
-
*/
|
|
13
|
-
addPeerForTx(peerId, txHash) {
|
|
14
|
-
const peerIdAsString = peerId.toString();
|
|
15
|
-
const existingLookup = this.lookup[txHash];
|
|
16
|
-
if (existingLookup === undefined) {
|
|
17
|
-
const newLookup = {};
|
|
18
|
-
newLookup[peerIdAsString] = true;
|
|
19
|
-
this.lookup[txHash] = newLookup;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
existingLookup[peerIdAsString] = true;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Determine if a peer has 'seen' a transaction.
|
|
26
|
-
* @param peerId - The peerId of the peer.
|
|
27
|
-
* @param txHash - The thHash of the transaction.
|
|
28
|
-
* @returns A boolean indicating if the transaction has been 'seen' by the peer.
|
|
29
|
-
*/
|
|
30
|
-
hasPeerSeenTx(peerId, txHash) {
|
|
31
|
-
const existingLookup = this.lookup[txHash];
|
|
32
|
-
if (existingLookup === undefined) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
const peerIdAsString = peerId.toString();
|
|
36
|
-
return !!existingLookup[peerIdAsString];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Updates the lookup from the result of settled txs
|
|
40
|
-
* These txs will be cleared out of the lookup.
|
|
41
|
-
* It is possible that some txs could still be gossiped for a
|
|
42
|
-
* short period of time meaning they come back into this lookup
|
|
43
|
-
* but this should be infrequent and cause no undesirable effects
|
|
44
|
-
* @param txHashes - The hashes of the newly settled transactions
|
|
45
|
-
*/
|
|
46
|
-
handleSettledTxs(txHashes) {
|
|
47
|
-
for (const txHash of txHashes) {
|
|
48
|
-
delete this.lookup[txHash];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia25vd25fdHhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcnZpY2Uva25vd25fdHhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOztHQUVHO0FBQ0gsTUFBTSxPQUFPLGFBQWE7SUFHeEI7UUFGUSxXQUFNLEdBQWtELEVBQUUsQ0FBQztJQUVwRCxDQUFDO0lBRWhCOzs7O09BSUc7SUFDSSxZQUFZLENBQUMsTUFBYyxFQUFFLE1BQWM7UUFDaEQsTUFBTSxjQUFjLEdBQUcsTUFBTSxDQUFDLFFBQVEsRUFBRSxDQUFDO1FBQ3pDLE1BQU0sY0FBYyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDM0MsSUFBSSxjQUFjLEtBQUssU0FBUyxFQUFFLENBQUM7WUFDakMsTUFBTSxTQUFTLEdBQStCLEVBQUUsQ0FBQztZQUNqRCxTQUFTLENBQUMsY0FBYyxDQUFDLEdBQUcsSUFBSSxDQUFDO1lBQ2pDLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLEdBQUcsU0FBUyxDQUFDO1lBQ2hDLE9BQU87UUFDVCxDQUFDO1FBQ0QsY0FBYyxDQUFDLGNBQWMsQ0FBQyxHQUFHLElBQUksQ0FBQztJQUN4QyxDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSSxhQUFhLENBQUMsTUFBYyxFQUFFLE1BQWM7UUFDakQsTUFBTSxjQUFjLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUMzQyxJQUFJLGNBQWMsS0FBSyxTQUFTLEVBQUUsQ0FBQztZQUNqQyxPQUFPLEtBQUssQ0FBQztRQUNmLENBQUM7UUFDRCxNQUFNLGNBQWMsR0FBRyxNQUFNLENBQUMsUUFBUSxFQUFFLENBQUM7UUFDekMsT0FBTyxDQUFDLENBQUMsY0FBYyxDQUFDLGNBQWMsQ0FBQyxDQUFDO0lBQzFDLENBQUM7SUFFRDs7Ozs7OztPQU9HO0lBQ0ksZ0JBQWdCLENBQUMsUUFBa0I7UUFDeEMsS0FBSyxNQUFNLE1BQU0sSUFBSSxRQUFRLEVBQUUsQ0FBQztZQUM5QixPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDN0IsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
|
package/src/service/known_txs.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type PeerId } from '@libp2p/interface';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Keeps a record of which Peers have 'seen' which transactions.
|
|
5
|
-
*/
|
|
6
|
-
export class KnownTxLookup {
|
|
7
|
-
private lookup: { [key: string]: { [key: string]: boolean } } = {};
|
|
8
|
-
|
|
9
|
-
constructor() {}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Inform this lookup that a peer has 'seen' a transaction.
|
|
13
|
-
* @param peerId - The peerId of the peer that has 'seen' the transaction.
|
|
14
|
-
* @param txHash - The thHash of the 'seen' transaction.
|
|
15
|
-
*/
|
|
16
|
-
public addPeerForTx(peerId: PeerId, txHash: string) {
|
|
17
|
-
const peerIdAsString = peerId.toString();
|
|
18
|
-
const existingLookup = this.lookup[txHash];
|
|
19
|
-
if (existingLookup === undefined) {
|
|
20
|
-
const newLookup: { [key: string]: boolean } = {};
|
|
21
|
-
newLookup[peerIdAsString] = true;
|
|
22
|
-
this.lookup[txHash] = newLookup;
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
existingLookup[peerIdAsString] = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Determine if a peer has 'seen' a transaction.
|
|
30
|
-
* @param peerId - The peerId of the peer.
|
|
31
|
-
* @param txHash - The thHash of the transaction.
|
|
32
|
-
* @returns A boolean indicating if the transaction has been 'seen' by the peer.
|
|
33
|
-
*/
|
|
34
|
-
public hasPeerSeenTx(peerId: PeerId, txHash: string) {
|
|
35
|
-
const existingLookup = this.lookup[txHash];
|
|
36
|
-
if (existingLookup === undefined) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
const peerIdAsString = peerId.toString();
|
|
40
|
-
return !!existingLookup[peerIdAsString];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Updates the lookup from the result of settled txs
|
|
45
|
-
* These txs will be cleared out of the lookup.
|
|
46
|
-
* It is possible that some txs could still be gossiped for a
|
|
47
|
-
* short period of time meaning they come back into this lookup
|
|
48
|
-
* but this should be infrequent and cause no undesirable effects
|
|
49
|
-
* @param txHashes - The hashes of the newly settled transactions
|
|
50
|
-
*/
|
|
51
|
-
public handleSettledTxs(txHashes: string[]) {
|
|
52
|
-
for (const txHash of txHashes) {
|
|
53
|
-
delete this.lookup[txHash];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|