-
Notifications
You must be signed in to change notification settings - Fork 446
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
feat: track failed/successful dials per-address #2033
base: main
Are you sure you want to change the base?
Changes from 1 commit
90bfc6d
3b31fdd
cc8196c
7836623
40dd225
3296f11
308097f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -75,14 +75,11 @@ describe('merge', () => { | |||||
}) | ||||||
|
||||||
expect(updated).to.have.property('addresses').that.deep.equals([{ | ||||||
multiaddr: addr1, | ||||||
isCertified: false | ||||||
multiaddr: addr1 | ||||||
}, { | ||||||
multiaddr: addr3, | ||||||
isCertified: false | ||||||
multiaddr: addr3 | ||||||
}, { | ||||||
multiaddr: addr2, | ||||||
isCertified: false | ||||||
multiaddr: addr2 | ||||||
}]) | ||||||
|
||||||
// other fields should be untouched | ||||||
|
@@ -244,4 +241,53 @@ describe('merge', () => { | |||||
expect(updated).to.have.property('tags').that.deep.equals(original.tags) | ||||||
expect(updated).to.have.property('protocols').that.deep.equals(original.protocols) | ||||||
}) | ||||||
|
||||||
it('merges addresses', async () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test also ensures |
||||||
const peer: PeerData = { | ||||||
addresses: [{ | ||||||
multiaddr: addr1, | ||||||
isCertified: true | ||||||
}, { | ||||||
multiaddr: addr2, | ||||||
lastFailure: 5 | ||||||
}], | ||||||
metadata: { | ||||||
foo: Uint8Array.from([0, 1, 2]) | ||||||
}, | ||||||
tags: { | ||||||
tag1: { value: 10 } | ||||||
}, | ||||||
protocols: [ | ||||||
'/foo/bar' | ||||||
], | ||||||
peerRecordEnvelope: Uint8Array.from([3, 4, 5]) | ||||||
} | ||||||
|
||||||
const original = await peerStore.save(otherPeerId, peer) | ||||||
const updated = await peerStore.merge(otherPeerId, { | ||||||
addresses: [{ | ||||||
multiaddr: addr1, | ||||||
lastFailure: 10 | ||||||
}, { | ||||||
multiaddr: addr2, | ||||||
lastSuccess: 10 | ||||||
}] | ||||||
}) | ||||||
|
||||||
expect(updated).to.have.property('addresses').that.deep.equals([{ | ||||||
multiaddr: addr1, | ||||||
isCertified: true, | ||||||
lastFailure: 10 | ||||||
}, { | ||||||
multiaddr: addr2, | ||||||
lastFailure: 5, | ||||||
lastSuccess: 10 | ||||||
}]) | ||||||
|
||||||
// other fields should be untouched | ||||||
expect(updated).to.have.property('metadata').that.deep.equals(original.metadata) | ||||||
expect(updated).to.have.property('tags').that.deep.equals(original.tags) | ||||||
expect(updated).to.have.property('protocols').that.deep.equals(original.protocols) | ||||||
expect(updated).to.have.property('peerRecordEnvelope').that.deep.equals(original.peerRecordEnvelope) | ||||||
}) | ||||||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason to use Number here instead of
BigInt
as is used elsewhere in this PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is a timestamp, the max value of which can exceed 32 bits so we need to use a 64 bit number in the protobuf to store it, which means we need to represent it as a BigInt, but this is overkill for actual time values.
We can refactor this once ipfs/protons#112 is implemented to have protons serialize/deserialize to
Number
instead ofBigInt
.