public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
* [Bitcoin-development] Trickle in CNode::SendMessages
@ 2011-12-29 22:05 Michael Grønager
  2011-12-30  7:38 ` Michael Grønager
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Grønager @ 2011-12-29 22:05 UTC (permalink / raw)
  To: Bitcoin Dev

In CNode::SendMessages there is a trickle algorithm. Judging from the comments it is supposed to:

* at each update round a new (random) trickle node is chosen, with 120 nodes and an average round time of 100ms (the sleep) we will have moved through roughly all nodes every 12-15 seconds.
* when a node is the trickle node it will get to send all its pending addresses to its corresponding peer.
* when a node is not trickle node (the rest of the nodes) we send transaction-invs, however, only 1/4 of them - the rest is pushed to wait for the next round and would eventually get sent.

However, the way the 1/4 of the invs are chosen is by: 
	(inv.getHash() ^ hashSalt) & 3 == 0

As hashSalt is a constant (static, generated on start up) and as the hash of an inv is constant for the inv too, the other 3/4 will never get sent and hence it does not make sense to carry them around from round to round:
	if (fTrickleWait) vInvWait.push_back(inv); 
and:
	pto->vInventoryToSend = vInvWait;

The hashSalt will be different for each node in the peer-to-peer network and hence as long as we have much more than 4 nodes all tx'es will be sent around.

Ironically, this (wrong?) implementation divides the inv forwarding hash space into 4, along the same lines as we discussed last week for DHTs...

I suggest to either keep the algorithm as is, but remove the redundant vInvWait stuff, or to change the algorithm to e.g. push the tx'es into a multimap (invHash^hashSalt, invHash) and choose the first 25% in each round. 

The last alternative is that I have misunderstood the code... - if so please correct me ;)

Happy New Year!

Michael




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-30  7:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-29 22:05 [Bitcoin-development] Trickle in CNode::SendMessages Michael Grønager
2011-12-30  7:38 ` Michael Grønager

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox