Compare commits

...

5 Commits

Author SHA1 Message Date
ed2dbd9bea fix: return empty array when no multiaddrs are known
Returning `undefined` makes the address length check in [dialler/index.js](https://github.com/libp2p/js-libp2p/blob/master/src/dialer/index.js#L73-L75)
fail with `cannot read property length of undefined` so the change
here is to always return an array, but it might be empty if we don't
know any multiaddrs for the given peer.
2020-07-20 10:51:29 +01:00
856b38de67 chore: add migration guide template (#711) 2020-07-16 18:14:02 +02:00
798d7b73c1 chore: release version v0.28.7 2020-07-14 19:13:55 +02:00
f2d0d8b51d chore: update contributors 2020-07-14 19:13:54 +02:00
999c1b7740 fix: retimer reschedule does not work as interval (#710)
* fix: retimer reschedule does not work as interval

* chore: apply suggestions from code review

Co-authored-by: Jacob Heun <jacobheun@gmail.com>

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-07-14 19:11:29 +02:00
7 changed files with 63 additions and 20 deletions

View File

@ -1,3 +1,13 @@
<a name="0.28.7"></a>
## [0.28.7](https://github.com/libp2p/js-libp2p/compare/v0.28.6...v0.28.7) (2020-07-14)
### Bug Fixes
* retimer reschedule does not work as interval ([#710](https://github.com/libp2p/js-libp2p/issues/710)) ([999c1b7](https://github.com/libp2p/js-libp2p/commit/999c1b7))
<a name="0.28.6"></a>
## [0.28.6](https://github.com/libp2p/js-libp2p/compare/v0.28.5...v0.28.6) (2020-07-14)

45
MIGRATION_TEMPLATE.md Normal file
View File

@ -0,0 +1,45 @@
<!--Specify versions for migration below-->
# Migrating to libp2p@__
A migration guide for refactoring your application code from libp2p v__ to v__.
## Table of Contents
- [API](#api)
- [Module Updates](#module-updates)
## API
<!--Describe breaking APIs with examples for Before and After
Example:
### Peer Discovery
__Describe__
**Before**
```js
```
**After**
```js
```
-->
## Module Updates
With this release you should update the following libp2p modules if you are relying on them:
<!--Specify module versions in JSON for migration below.
It's recommended to check package.json changes for this:
`git diff <release> <prev> -- package.json`
-->
```json
```

View File

@ -1,6 +1,6 @@
{
"name": "libp2p",
"version": "0.28.6",
"version": "0.28.7",
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",

View File

@ -178,7 +178,7 @@ class ConnectionManager extends EventEmitter {
const total = received + sent
this._checkMaxLimit('maxData', total)
log('metrics update', total)
this._timer.reschedule(this._options.pollInterval)
this._timer = retimer(this._checkMetrics, this._options.pollInterval)
}
/**
@ -291,17 +291,9 @@ class ConnectionManager extends EventEmitter {
async _autoDial () {
const minConnections = this._options.minConnections
const recursiveTimeoutTrigger = () => {
if (this._autoDialTimeout) {
this._autoDialTimeout.reschedule(this._options.autoDialInterval)
} else {
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
}
}
// Already has enough connections
if (this.size >= minConnections) {
recursiveTimeoutTrigger()
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
return
}
@ -332,7 +324,7 @@ class ConnectionManager extends EventEmitter {
}
}
recursiveTimeoutTrigger()
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
}
/**

View File

@ -128,11 +128,7 @@ class Stats extends EventEmitter {
* @returns {void}
*/
_resetComputeTimeout () {
if (this._timeout) {
this._timeout.reschedule(this._nextTimeout())
} else {
this._timeout = retimer(this._update, this._nextTimeout())
}
this._timeout = retimer(this._update, this._nextTimeout())
}
/**

View File

@ -179,7 +179,7 @@ class AddressBook extends Book {
const record = this.data.get(peerId.toB58String())
if (!record) {
return undefined
return []
}
return record.map((address) => {

View File

@ -323,10 +323,10 @@ describe('addressBook', () => {
throw new Error('invalid peerId should throw error')
})
it('returns undefined if no multiaddrs are known for the provided peer', () => {
it('returns empty array if no multiaddrs are known for the provided peer', () => {
const addresses = ab.getMultiaddrsForPeer(peerId)
expect(addresses).to.not.exist()
expect(addresses).to.be.empty()
})
it('returns the multiaddrs stored', () => {