本文整理汇总了Java中com.google.bitcoin.core.TransactionBroadcaster类的典型用法代码示例。如果您正苦于以下问题:Java TransactionBroadcaster类的具体用法?Java TransactionBroadcaster怎么用?Java TransactionBroadcaster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionBroadcaster类属于com.google.bitcoin.core包,在下文中一共展示了TransactionBroadcaster类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PaymentChannelServerListener
import com.google.bitcoin.core.TransactionBroadcaster; //导入依赖的package包/类
/**
* Sets up a new payment channel server which listens on the given port.
*
* @param broadcaster The PeerGroup on which transactions will be broadcast - should have multiple connections.
* @param wallet The wallet which will be used to complete transactions
* @param timeoutSeconds The read timeout between messages. This should accommodate latency and client ECDSA
* signature operations.
* @param minAcceptedChannelSize The minimum amount of coins clients must lock in to create a channel. Clients which
* are unwilling or unable to lock in at least this value will immediately disconnect.
* For this reason, a fairly conservative value (in terms of average value spent on a
* channel) should generally be chosen.
* @param eventHandlerFactory A factory which generates event handlers which are created for each new connection
*/
public PaymentChannelServerListener(TransactionBroadcaster broadcaster, Wallet wallet,
final int timeoutSeconds, BigInteger minAcceptedChannelSize,
HandlerFactory eventHandlerFactory) throws IOException {
this.wallet = checkNotNull(wallet);
this.broadcaster = checkNotNull(broadcaster);
this.eventHandlerFactory = checkNotNull(eventHandlerFactory);
this.minAcceptedChannelSize = checkNotNull(minAcceptedChannelSize);
server = new NioServer(new StreamParserFactory() {
@Override
public ProtobufParser getNewParser(InetAddress inetAddress, int port) {
return new ServerHandler(new InetSocketAddress(inetAddress, port), timeoutSeconds).socketProtobufHandler;
}
});
}
示例2: makeRecorders
import com.google.bitcoin.core.TransactionBroadcaster; //导入依赖的package包/类
public static RecordingPair makeRecorders(final Wallet serverWallet, final TransactionBroadcaster mockBroadcaster) {
RecordingPair pair = new RecordingPair();
pair.serverRecorder = new RecordingServerConnection();
pair.server = new PaymentChannelServer(mockBroadcaster, serverWallet, Utils.COIN, pair.serverRecorder);
pair.clientRecorder = new RecordingClientConnection();
return pair;
}
示例3: broadcastTransaction
import com.google.bitcoin.core.TransactionBroadcaster; //导入依赖的package包/类
public void broadcastTransaction(final TransactionBroadcaster broadcaster,
final Transaction tx) {
new Thread() {
@Override
public void run() {
// Handle the future results just for logging.
try {
Futures.addCallback(broadcaster.broadcastTransaction(tx),
new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
mLogger.info("Successfully broadcast sweep tx: {}",
transaction);
}
@Override
public void onFailure(Throwable throwable) {
mLogger.error("Failed to broadcast sweep tx",
throwable);
}
});
} catch (Exception e) {
mLogger.error("Failed to broadcast sweep tx", e);
}
}
}.start();
}
示例4: PaymentChannelServerListener
import com.google.bitcoin.core.TransactionBroadcaster; //导入依赖的package包/类
/**
* Sets up a new payment channel server which listens on the given port.
*
* @param broadcaster The PeerGroup on which transactions will be broadcast - should have multiple connections.
* @param wallet The wallet which will be used to complete transactions
* @param timeoutSeconds The read timeout between messages. This should accommodate latency and client ECDSA
* signature operations.
* @param minAcceptedChannelSize The minimum amount of coins clients must lock in to create a channel. Clients which
* are unwilling or unable to lock in at least this value will immediately disconnect.
* For this reason, a fairly conservative value (in terms of average value spent on a
* channel) should generally be chosen.
* @param eventHandlerFactory A factory which generates event handlers which are created for each new connection
*/
public PaymentChannelServerListener(TransactionBroadcaster broadcaster, Wallet wallet,
final int timeoutSeconds, BigInteger minAcceptedChannelSize,
HandlerFactory eventHandlerFactory) throws IOException {
this.wallet = checkNotNull(wallet);
this.broadcaster = checkNotNull(broadcaster);
this.eventHandlerFactory = checkNotNull(eventHandlerFactory);
this.minAcceptedChannelSize = checkNotNull(minAcceptedChannelSize);
this.timeoutSeconds = timeoutSeconds;
}