Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

chore: update to new multiformats #220

Merged
merged 9 commits into from
Jul 7, 2021
Merged
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
5 changes: 3 additions & 2 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
bundlesize: { maxSize: '190kB' }
build: {
bundlesizeMax: '182kB'
}
}

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ os:

before_install:
# modules with pre-built binaries may not have deployed versions for bleeding-edge node so this lets us fall back to building from source
- npm install -g node-pre-gyp
- npm install -g @mapbox/node-pre-gyp

script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
Expand Down
31 changes: 12 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
"main": "src/index.js",
"scripts": {
"lint": "aegir lint",
"lint": "aegir ts -p check && aegir lint",
"prepare": "npm run build",
"build": "npm run build:proto && npm run build:proto-types && aegir build",
"build:proto": "pbjs -t static-module -w commonjs -r libp2p-dht-message --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/message/dht.js ./src/message/dht.proto",
Expand Down Expand Up @@ -45,53 +45,46 @@
"types": "dist/src/index.d.ts",
"dependencies": {
"abort-controller": "^3.0.0",
"cids": "^1.1.5",
"debug": "^4.3.1",
"err-code": "^3.0.0",
"hashlru": "^2.3.0",
"heap": "~0.2.6",
"interface-datastore": "^4.0.0",
"interface-datastore": "^5.1.1",
"it-first": "^1.0.4",
"it-length-prefixed": "^5.0.2",
"it-pipe": "^1.1.0",
"k-bucket": "^5.0.0",
"libp2p-crypto": "^0.19.0",
"libp2p-interfaces": "^0.10.0",
"libp2p-record": "^0.10.0",
"multiaddr": "^9.0.0",
"multihashing-async": "^2.1.0",
"p-filter": "^2.1.0",
"libp2p-crypto": "^0.19.5",
"libp2p-interfaces": "^0.12.1",
"libp2p-record": "^0.10.4",
"multiaddr": "^10.0.0",
"multiformats": "^9.0.0",
"p-map": "^4.0.0",
"p-queue": "^6.6.2",
"p-timeout": "^4.1.0",
"p-times": "^3.0.0",
"peer-id": "^0.14.2",
"promise-to-callback": "^1.0.0",
"peer-id": "^0.15.0",
"protobufjs": "^6.10.2",
"streaming-iterables": "^5.0.4",
"streaming-iterables": "^6.0.0",
"uint8arrays": "^2.1.4",
"varint": "^6.0.0",
"xor-distance": "^2.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.5",
"aegir": "^30.3.0",
"aegir": "^33.1.2",
"async-iterator-all": "^1.0.0",
"chai": "^4.3.0",
"chai-checkmark": "^1.0.1",
"datastore-level": "^5.0.0",
"datastore-level": "^6.0.0",
"delay": "^5.0.0",
"dirty-chai": "^2.0.1",
"it-pair": "^1.0.0",
"libp2p": "^0.31.0",
"lodash": "^4.17.11",
"lodash.random": "^3.2.0",
"lodash.range": "^3.2.0",
"p-defer": "^3.0.0",
"p-each-series": "^2.1.0",
"p-map-series": "^2.1.0",
"p-retry": "^4.2.0",
"sinon": "^10.0.0"
"sinon": "^11.1.1"
},
"contributors": [
"Vasco Santos <vasco.santos@moxy.studio>",
Expand Down
2 changes: 1 addition & 1 deletion src/content-routing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Query = require('../query')
const utils = require('../utils')

/**
* @typedef {import('cids')} CID
* @typedef {import('multiformats/cid').CID} CID
* @typedef {import('peer-id')} PeerId
* @typedef {import('multiaddr').Multiaddr} Multiaddr
*/
Expand Down
18 changes: 9 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Record = libp2pRecord.Record
* @typedef {import('interface-datastore').Datastore} Datastore
* @typedef {import('libp2p/src/dialer')} Dialer
* @typedef {import('libp2p/src/registrar')} Registrar
* @typedef {import('cids')} CID
* @typedef {import('multiformats/cid').CID} CID
* @typedef {import('multiaddr').Multiaddr} Multiaddr
* @typedef {object} PeerData
* @property {PeerId} id
Expand Down Expand Up @@ -235,14 +235,16 @@ class KadDHT extends EventEmitter {

/**
* Start listening to incoming connections.
*
* @returns {Promise<void>}
*/
async start () {
start () {
if (this._running) {
return
}

this._running = true
this.providers.start()
this._queryManager.start()
await this.network.start()
this.network.start()

// Start random walk, it will not run if it's disabled
this.randomWalk.start()
Expand All @@ -251,15 +253,13 @@ class KadDHT extends EventEmitter {
/**
* Stop accepting incoming connections and sending outgoing
* messages.
*
* @returns {Promise<void>}
*/
stop () {
this._running = false
this.randomWalk.stop()
this.providers.stop()
this.network.stop()
this._queryManager.stop()
return this.network.stop()
this.providers.stop()
}

/**
Expand Down
55 changes: 44 additions & 11 deletions src/message/dht.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,34 @@ export class Record implements IRecord {
constructor(p?: IRecord);

/** Record key. */
public key: Uint8Array;
public key?: (Uint8Array|null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this generated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm not sure why this changed, new patch release of protobufjs I guess?


/** Record value. */
public value: Uint8Array;
public value?: (Uint8Array|null);

/** Record author. */
public author: Uint8Array;
public author?: (Uint8Array|null);

/** Record signature. */
public signature: Uint8Array;
public signature?: (Uint8Array|null);

/** Record timeReceived. */
public timeReceived: string;
public timeReceived?: (string|null);

/** Record _key. */
public _key?: "key";

/** Record _value. */
public _value?: "value";

/** Record _author. */
public _author?: "author";

/** Record _signature. */
public _signature?: "signature";

/** Record _timeReceived. */
public _timeReceived?: "timeReceived";

/**
* Encodes the specified Record message. Does not implicitly {@link Record.verify|verify} messages.
Expand Down Expand Up @@ -114,23 +129,35 @@ export class Message implements IMessage {
constructor(p?: IMessage);

/** Message type. */
public type: Message.MessageType;
public type?: (Message.MessageType|null);

/** Message clusterLevelRaw. */
public clusterLevelRaw: number;
public clusterLevelRaw?: (number|null);

/** Message key. */
public key: Uint8Array;
public key?: (Uint8Array|null);

/** Message record. */
public record: Uint8Array;
public record?: (Uint8Array|null);

/** Message closerPeers. */
public closerPeers: Message.IPeer[];

/** Message providerPeers. */
public providerPeers: Message.IPeer[];

/** Message _type. */
public _type?: "type";

/** Message _clusterLevelRaw. */
public _clusterLevelRaw?: "clusterLevelRaw";

/** Message _key. */
public _key?: "key";

/** Message _record. */
public _record?: "record";

/**
* Encodes the specified Message message. Does not implicitly {@link Message.verify|verify} messages.
* @param m Message message or plain object to encode
Expand Down Expand Up @@ -214,13 +241,19 @@ export namespace Message {
constructor(p?: Message.IPeer);

/** Peer id. */
public id: Uint8Array;
public id?: (Uint8Array|null);

/** Peer addrs. */
public addrs: Uint8Array[];

/** Peer connection. */
public connection: Message.ConnectionType;
public connection?: (Message.ConnectionType|null);

/** Peer _id. */
public _id?: "id";

/** Peer _connection. */
public _connection?: "connection";

/**
* Encodes the specified Peer message. Does not implicitly {@link Message.Peer.verify|verify} messages.
Expand Down
Loading