private void disconnectClients() { if (clients != null) { clients.stopAllAsync(); clients = null; } }
public boolean equals(BlockHeader blockHeader) { return (this.getBlockHeight() == blockHeader.getBlockHeight() && this.getTimestamp() == this.getTimestamp()); } }
/** * Adds an event listener object. Methods on this object are called when something interesting happens, * like new connection to a server. The listener is executed by {@link org.bitcoinj.utils.Threading#USER_THREAD}. */ @Override public void addEventListener(ConnectionEventListener listener) { addEventListener(listener, Threading.USER_THREAD); }
public ServerClient(CoinAddress coinAddress, ConnectivityHelper connectivityHelper) { this.connectivityHelper = connectivityHelper; eventListeners = new CopyOnWriteArrayList<ListenerRegistration<ConnectionEventListener>>(); failedAddresses = new HashSet<ServerAddress>(); type = coinAddress.getType(); addresses = ImmutableList.copyOf(coinAddress.getAddresses()); createStratumClient(); }
public void ping() { ping(null); }
private ServerClients getServerClients(Wallet wallet) { ServerClients newClients = new ServerClients(Constants.DEFAULT_COINS_SERVERS, connHelper); if (application.getTxCachePath() != null) { newClients.setCacheDir(application.getTxCachePath(), Constants.TX_CACHE_SIZE); } return newClients; }
private String getEcUrl() { return getBaseUrl() + GET_REQUEST + GET_EC_BLOCK; }
/** * Queue transactions that are going to be fetched */ public void queueHistoryTransactions(List<HistoryTx> txs) { if (historyTransactions == null) { historyTransactions = Sets.newHashSet(txs); historyTxHashes = fillTransactions(txs); stateMustBeApplied = true; } }
@Override public void disconnect() { if (blockchainConnection != null) { blockchainConnection.stopAsync(); } }
@Override public void run() { if (isActivelyConnected()) { reconnectAt = 0; retrySeconds = 0; } } };
@Override public void addEventListener(ConnectionEventListener listener) { addEventListener(listener, Threading.USER_THREAD); }
public ServerClients(List<CoinAddress> coinAddresses, ConnectivityHelper connectivityHelper) { this.connectivityHelper = connectivityHelper; setupAddresses(coinAddresses); }
private void setupAddresses(List<CoinAddress> coins) { for (CoinAddress coinAddress : coins) { addresses.put(coinAddress.getType(), coinAddress); } }
private HashSet<Sha256Hash> fillTransactions(Iterable<? extends HistoryTx> txs) { HashSet<Sha256Hash> transactionHashes = new HashSet<>(); for (HistoryTx tx : txs) { transactionHashes.add(tx.getTxHash()); } return transactionHashes; }
private void subscribeToBlockchain() { lock.lock(); try { if (blockchainConnection != null) { blockchainConnection.subscribeToBlockchain(this); } } finally { lock.unlock(); } }
private String getTransactionBytesUrl(String txId) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_TRANSACTION_BYTES) .append("&transaction=").append(txId); return builder.toString(); }
protected Void doInBackground(Void... params) { startSweeping(); serverClients.stopAllAsync(); return null; }
/** * Queue transactions that are going to be fetched */ public void queueUnspentTransactions(List<UnspentTx> txs) { if (unspentTransactions == null) { unspentTransactions = Sets.newHashSet(txs); unspentTxHashes = fillTransactions(txs); stateMustBeApplied = true; } }
private String getBlockChainTxsUrl(String address) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_BLOCKCHAIN_TXS) .append("&account=").append(address); return builder.toString(); }
private String getTransactionUrl(String txHash) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_TRANSACTION) .append("&fullHash=").append(txHash); return builder.toString(); }