Package org.bitcoinj.core
Class TransactionBroadcast
java.lang.Object
org.bitcoinj.core.TransactionBroadcast
Represents a single transaction broadcast that we are performing. A broadcast occurs after a new transaction is created
(typically by a
Wallet
) and 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
Modifier and TypeClassDescriptionstatic interface
An interface for receiving progress information on the propagation of the tx, from 0.0 to 1.0 -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.util.concurrent.ListenableFuture<Transaction>
static TransactionBroadcast
createMockBroadcast
(Transaction tx, com.google.common.util.concurrent.SettableFuture<Transaction> future) com.google.common.util.concurrent.ListenableFuture<Transaction>
future()
void
setDropPeersAfterBroadcast
(boolean dropPeersAfterBroadcast) void
setMinConnections
(int minConnections) void
Sets the given callback for receiving progress values, which will run on the user thread.void
setProgressCallback
(TransactionBroadcast.ProgressCallback callback, Executor executor) Sets the given callback for receiving progress values, which will run on the given executor.
-
Field Details
-
random
Used for shuffling the peers before broadcast: unit tests can replace this to make themselves deterministic.
-
-
Method Details
-
createMockBroadcast
public static TransactionBroadcast createMockBroadcast(Transaction tx, com.google.common.util.concurrent.SettableFuture<Transaction> future) -
future
-
setMinConnections
public void setMinConnections(int minConnections) -
setDropPeersAfterBroadcast
public void setDropPeersAfterBroadcast(boolean dropPeersAfterBroadcast) -
broadcast
-
setProgressCallback
Sets the given callback for receiving progress values, which will run on the user thread. SeeThreading
for 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 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.
-