distance as paramter (like arbiter)
Closed this issue · 10 comments
It should make KBucket
more flexible. Thoughts?
Technically, since we're in JavaScript, and distance
is only used via KBucket.distance
, it's already parametrizable via monkey patching. For example:
const KBucket = require("k-bucket");
KBucket.distance = () => Math.random() * 100;
Heh.. I think this highlights the inconsistency of the API though :)
Yes, it will work, but what if we have 2 buckets and want 2 different algorithms for distance?
I agree, parameterized distance would be a way to do that. You are using buckets with 2 different distance algorithms?
You are using buckets with 2 different distance algorithms?
No.. it's just abstract example.
I think a parameterized distance would make the KBucket API more consistent with itself.
I have some edits I'll promote soon for you to take a look at.
@tristanls it's really cool!
K, thank you for the feedback. Releasing 3.1.0.