Package org.bitcoinj.core
Class TransactionBroadcast
- java.lang.Object
 - 
- org.bitcoinj.core.TransactionBroadcast
 
 
- 
public class TransactionBroadcast extends java.lang.ObjectRepresents a single transaction broadcast that we are performing. A broadcast occurs after a new transaction is created (typically by aWalletand needs to be sent to the network. A broadcast can succeed or fail. A success is defined as seeing the transaction be announced by peers via inv messages, thus indicating their acceptance. A failure is defined as not reaching acceptance within a timeout period, or getting an explicit reject message from a peer indicating that the transaction was not acceptable. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTransactionBroadcast.ProgressCallbackAn interface for receiving progress information on the propagation of the tx, from 0.0 to 1.0 
- 
Field Summary
Fields Modifier and Type Field Description static java.util.RandomrandomUsed for shuffling the peers before broadcast: unit tests can replace this to make themselves deterministic. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.util.concurrent.ListenableFuture<Transaction>broadcast()static TransactionBroadcastcreateMockBroadcast(Transaction tx, com.google.common.util.concurrent.SettableFuture<Transaction> future)com.google.common.util.concurrent.ListenableFuture<Transaction>future()voidsetDropPeersAfterBroadcast(boolean dropPeersAfterBroadcast)voidsetMinConnections(int minConnections)voidsetProgressCallback(TransactionBroadcast.ProgressCallback callback)Sets the given callback for receiving progress values, which will run on the user thread.voidsetProgressCallback(TransactionBroadcast.ProgressCallback callback, java.util.concurrent.Executor executor)Sets the given callback for receiving progress values, which will run on the given executor. 
 - 
 
- 
- 
Method Detail
- 
createMockBroadcast
public static TransactionBroadcast createMockBroadcast(Transaction tx, com.google.common.util.concurrent.SettableFuture<Transaction> future)
 
- 
future
public com.google.common.util.concurrent.ListenableFuture<Transaction> future()
 
- 
setMinConnections
public void setMinConnections(int minConnections)
 
- 
setDropPeersAfterBroadcast
public void setDropPeersAfterBroadcast(boolean dropPeersAfterBroadcast)
 
- 
broadcast
public com.google.common.util.concurrent.ListenableFuture<Transaction> broadcast()
 
- 
setProgressCallback
public void setProgressCallback(TransactionBroadcast.ProgressCallback callback)
Sets the given callback for receiving progress values, which will run on the user thread. SeeThreadingfor details. If the broadcast has already started then the callback will be invoked immediately with the current progress. 
- 
setProgressCallback
public void setProgressCallback(TransactionBroadcast.ProgressCallback callback, @Nullable java.util.concurrent.Executor executor)
Sets the given callback for receiving progress values, which will run on the given executor. If the executor is null then the callback will run on a network thread and may be invoked multiple times in parallel. You probably want to provide your UI thread or Threading.USER_THREAD for the second parameter. If the broadcast has already started then the callback will be invoked immediately with the current progress. 
 - 
 
 -