Satoshi Client Transaction Exchange
This is the approved revision of this page, as well as being the most recent.
The Satoshi client advertises locally generated transactions and relays transactions from other nodes. This article describes the operations that deal with this exchange of transactions.
Transactions are exchanged only if they are standard and valid.
The client periodically calls SendMessages() (in main.cpp) which calls ResendWalletTransactions to send transactions generated locally. This routine looks to see if there has been a new block since last time, and if so, and the local transaction are still not in a block, then the transactions are sent to all nodes. This is done only about every 30 minutes.
Transactions are only rebroadcast if they have a timestamp at least 5 minutes older than the last block was received. They are sorted and sent oldest first.
The client periodically calls SendMessages() (in main.cpp) which determines if a message should be sent to a remote node. For each message processing iteration, one node is chosen as the "trickle node". This node is the only one chosen to receive an "addr" message, if appropriate.
In the section for inventory, the client sends 1/4 of the transaction inventory, determined randomly, UNLESS they are the trickle node, in which case they receive ALL transactions. Yes, that seems reversed, but it is what it is. If the node is to receive 1/4 (not all), then the code also avoids sending any transactions that came from the local wallet. The comments indicate this is intended to increase privacy.
When the client receives a transaction via a "tx" messages, it calls RelayMessage, which calls RelayInventory, which queues the inventory to be sent to all other nodes.