public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: "Michael Grønager" <gronager@ceptacle•com>
To: Bitcoin Dev <bitcoin-development@lists•sourceforge.net>
Subject: [Bitcoin-development] Trickle in CNode::SendMessages
Date: Thu, 29 Dec 2011 23:05:55 +0100	[thread overview]
Message-ID: <AB205206-AC96-4A95-B100-E8F4461B08C5@ceptacle.com> (raw)

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




             reply	other threads:[~2011-12-29 22:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-29 22:05 Michael Grønager [this message]
2011-12-30  7:38 ` Michael Grønager

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AB205206-AC96-4A95-B100-E8F4461B08C5@ceptacle.com \
    --to=gronager@ceptacle$(echo .)com \
    --cc=bitcoin-development@lists$(echo .)sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox