Add enhanced bootstrap mechanism - #39
Closed
fonic wants to merge 2 commits into
Closed
Conversation
Closed
Extend debug message logging / debug output: - add support for message types (debug, info, warning, error) - introduce logging macros to easily log messages (debugf, infof, warnf, errorf) - log messages to user-defined callback instead of file so that application may be decide how to handle debug output - add string conversion functions that may be used in printf-style function calls (address family, IP protocol version, bucket/node ID, socket address, etc.) - add DHT_LOG_ defines to control certain features - add function to retrieve statistics (buckets, good nodes, dubious nodes, total nodes) - modify dump_bucket() and dht_dump_tables() to output tables - migrate all debugf calls to make use of the new capabilities - add additional debug output - modify dht-example to make use of the new capabilities
Add enhanced bootstrap mechanism: - add data structures 'bootstrap' and 'bootstrap_node' - add bootstrap states (failed, disabled, complete, enabled, running) - add defines 'DHT_BOOTSTRAP_...' - add bootstrap timer 'bootstrap_time' - add 'bootstrap_periodic()', 'bootstrap_switch_state()', 'bootstrap_ _update_timer()' and 'random_bucket()' - add 'dht_add_bootstrap_node()', 'dht_enable_bootstrap()' and 'dht_ bootstrap_state()' - modify 'dht_init()' to initialize and 'dht_uninit()' to free boot- strap resources - modify 'dht_periodic()', 'new_node()', 'neighbourhood_maintenance()' and 'bucket_maintenance()' - add 'dump_bootstrap_nodes()' and modify 'dump_tables()' to list bootstrap nodes - modify dht-example to make use of this feature
Owner
|
Rejected, sorry. The bootrstrap mechanism should live in the client, not in the library. If you cannot implement your favourite bootstrap mechanism in the client, this means that the interfaces provided by the library are deficient, and you should concentrate on designing the right interfaces. What is more, the bootstrap mechanism you propose is rather hackish, and introduces a number of weird dependencies to the code (adding nodes with a fake id? Pinging nodes from Finally, your patch makes a number of gratuitious stylistic changes (adding an overly-complex logging mechanism, replacing conditionals with switches, and even replacing spaces with tabs), which makes it next to impossible to review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an enhanced bootstrapping mechanism based on bittorrent/libbtdht. My goal was to create a mechanism that is configurable/flexible, fast (while not overloading the network) and implementable with minimal changes to existing code. I think this goal is reached quite well.
Additions:
bootstrapandbootstrap_nodeDHT_BOOTSTRAP_...defines to configure bootstrap behaviorbootstrap_timeused bydht_periodic()bootstrap_periodic(), which does the main work and is called bydht_periodic()while bootstrappingbootstrap_update_timer(),bootstrap_switch_state(),random_bucket()anddump_bootstrap_nodes()dht_add_bootstrap_node()to add bootstrap nodes to internal listsdht_enable_bootstrap()to enable/disable bootstrappingdht_bootstrap_state()to query current bootstrap stateChanges:
dht_init()initializes bootstrap data structuresdht_uninit()frees allocated bootstrap resourcesnew_node()will not ping dubious nodes while address family is bootstrappingneighbourhood_maintenance()will not do anything while address family is bootstrappingbucket_maintenance()will not do anything while address family is bootstrapping and will not consider both address families for find_node while bootstrappingdump_tables()will list bootstrap nodes usingdump_bootstrap_nodes()Bootstrap mechanism:
dht_add_bootstrap_node()dht_enable_bootstrap(), switches state to 'enabled' and sets bootstrap timer to 'now'dht_periodic()callsbootstrap_periodic()based on bootstrap timerbootstrap_periodic()adds bootstrap nodes from internal list to routing table using fake ids (myid, first bit flipped, last 4 bytes randomized), switches state to 'running' and updates bootstrap timerbootstrap_periodic()is called periodically from now on:DHT_BOOTSTRAP_...constants are hit or all nodes have been processedCommand line for testing using well-known bootstrap nodes:
dht-example <port> 67.215.246.10 6881 82.221.103.244 6881 2001:41d0:c:5ac:5::1 6881 87.98.162.88 6881 212.129.33.59 6881 174.129.43.152 6881 2001:41d0:2:599c::5d71:2184 25401 104.168.32.188 25401Bootstrapping both IPv4 and IPv6 with default settings should take about 45-60s.
NOTE:
This is based on my PR #37 to make use of the enhanced debug output features.
Screenshot:
