Skip to content
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

add lastChange property #43

Merged
merged 1 commit into from Aug 21, 2017
Merged

Conversation

robertkowalski
Copy link
Contributor

Hi! I'm improving bittorrent-dht's handling of node-lists and how it handles unresponsive nodes.

This adds a lastChange property.

Each bucket should maintain a "last changed" property to indicate how "fresh" the 
contents  are. When a node in a bucket is pinged and it responds, or a node is added 
to a bucket, or a node in a bucket is replaced with another node, the bucket's last 
changed property should be updated. Buckets that have not been changed in 
15 minutes should be "refreshed."

from: http://www.bittorrent.org/beps/bep_0005.html#routing-table

The implementation / updates for the lastChange property should be done in "userland" as ping implementation is also handled there.

@robertkowalski
Copy link
Contributor Author

related: webtorrent/bittorrent-dht#20

@fanatid
Copy link
Contributor

fanatid commented Aug 14, 2017

Is it all changes? Where property lastChange is changed?

@robertkowalski
Copy link
Contributor Author

@robertkowalski
Copy link
Contributor Author

as i mentioned:

The implementation / updates for the lastChange property should be done in "userland" as the ping implementation is also handled there.

@fanatid
Copy link
Contributor

fanatid commented Aug 14, 2017

if you do this in "userland", why not create lastChange property in "userland"?

@robertkowalski
Copy link
Contributor Author

thank you for your question.

to initialise it and set it explicitly to null as a property for k-bucket

@fanatid
Copy link
Contributor

fanatid commented Aug 14, 2017

I checked https://github.com/webtorrent/bittorrent-dht/pull/172/files
That PR should work without this changes, right?

@robertkowalski
Copy link
Contributor Author

robertkowalski commented Aug 14, 2017 via email

@tristanls
Copy link
Owner

Maybe this can be addressed with clarification about what the API is? The contact is well defined in that only the contact.id property is used and any satellite properties are untouched and preserved. If we had a concept/definition of satellite data for the k-bucket itself (which we don't), that could be used to define how safe it is to add properties to k-bucket and how that should be done.

So, if we defined the properties on k-bucket something like arbiter, distance, localNodeId, numberOfNodesPerKBucket, numberOfNodesToPing, and root. As well as all properties starting with underscore _ are reserved. Then, it should be safe for anyone to attach other properties. Alternatively, we could define metadata (or some name like that) that could serve as a container for satellite data, so that lastChange would end up on kBucket.metadata.lastChange or similar.

It seems to me easier to define metadata property as an object to carry satellite data. That way we don't have to enumerate properties, methods, and privates as part of the definition, but instead could say, "put your stuff in metadata property on k-bucket and it will be safe there."

@robertkowalski
Copy link
Contributor Author

Thank you for the explanation. That makes sense and is really well thought.

I agree. Are you happy to merge when I switch over to metadata and document it?

@tristanls
Copy link
Owner

Yes. (not sure if you get notified if I only use emoji on your post 🙂 )

@robertkowalski
Copy link
Contributor Author

@tristanls i didn't get a notice from the emoji reaction. thanks for writing a separate message.

I changed the PR accordingly.

@tristanls tristanls merged commit 4fb760b into tristanls:master Aug 21, 2017
@robertkowalski robertkowalski deleted the last-changed branch August 21, 2017 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants