@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { //Log.d("BlocksDownloaded",block.getHashAsString()); Integer height=blockChain.getChainHead().getHeight(); synchronized (blocks) { blocks.put(block, height); if (blocks.keySet().size() >= 30) { blocks.remove(blocks.keySet().toArray()[blocks.keySet().size() - 1]); } } if(System.currentTimeMillis()-lastTimestamp>1000) { refreshUI(); lastTimestamp = System.currentTimeMillis(); } }
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if(!this.caughtUp) { if(blocksLeft == 0) { this.caughtUp = true; this.doneDownload(); this.future.set(Long.valueOf(peer.getBestHeight())); } if(blocksLeft >= 0 && this.originalBlocksLeft > 0) { double pct = 100.0D - 100.0D * ((double)blocksLeft / (double)this.originalBlocksLeft); if((int)pct != this.lastPercent) { this.lastBlockDate = new Date(block.getTimeSeconds() * 1000L); this.progress(pct, blocksLeft, this.lastBlockDate); this.lastPercent = (int)pct; } } } }
@Override public void onBlocksDownloaded(Peer arg0, Block arg1, @Nullable FilteredBlock arg2, int arg3) { System.out.println("received block"); boolean receivedBcastAnnouncmnt = false; Map<Sha256Hash, Transaction> assocTxs = arg2.getAssociatedTransactions(); for(Transaction tx : assocTxs.values()) { System.out.println("from within mixpartner discovery " + tx); if(tx.getOutputs().size() > 1 && BroadcastAnnouncement.isBroadcastAnnouncementScript(tx.getOutput(1).getScriptBytes())) //&& !wallet.isTransactionRelevant(tx)) { //tx.getInput(0).getScriptSig().getChunks().get(0) { if(!this.broadcasts.contains(tx) && wallet.getTransaction(tx.getHash()) == null) { this.broadcasts.add(tx); receivedBcastAnnouncmnt = true; } } } if(receivedBcastAnnouncmnt) { for(BroadcastAnnouncementChangeEventListener l : listeners) { l.onBroadcastAnnouncementChanged(); } } }
/** * Used by {@link Peer} to decide whether or not to discard this block and any blocks building upon it, in case * the Bloom filter used to request them may be exhausted, that is, not have sufficient keys in the deterministic * sequence within it to reliably find relevant transactions. */ public boolean checkForFilterExhaustion(FilteredBlock block) { keyChainGroupLock.lock(); try { int epoch = keyChainGroup.getCombinedKeyLookaheadEpochs(); for (Transaction tx : block.getAssociatedTransactions().values()) { markKeysAsUsed(tx); } int newEpoch = keyChainGroup.getCombinedKeyLookaheadEpochs(); checkState(newEpoch >= epoch); // If the key lookahead epoch has advanced, there was a call to addKeys and the PeerGroup already has a // pending request to recalculate the filter queued up on another thread. The calling Peer should abandon // block at this point and await a new filter before restarting the download. return newEpoch > epoch; } finally { keyChainGroupLock.unlock(); } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (caughtUp) return; if (blocksLeft == 0) { caughtUp = true; doneDownload(); future.set(peer.getBestHeight()); } if (blocksLeft < 0 || originalBlocksLeft <= 0) return; double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft)); if ((int) pct != lastPercent) { progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000)); lastPercent = (int) pct; } }
/** * * @param peer * @param block * @param filteredBlock * @param blocksLeft */ @Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft); // to avoid overhead on notification, only 100th blocks or the last ones if (blocksLeft % 100 == 0 || blocksLeft < 10) { for (CoinActionCallback<CurrencyCoin> callback : _callbacks) { callback.onBlocksDownloaded(_bitcoinManager.getCurrencyCoin(), this.lastPercent, blocksLeft, this.lastBlockDate); } } }
/** * * @param peer * @param block * @param filteredBlock * @param blocksLeft */ @Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft); // to avoid overhead on notification, only 100th blocks or the last ones if (blocksLeft % 100 == 0 || blocksLeft < 10) { for (CoinActionCallback<CurrencyCoin> callback : _callbacks) { callback.onBlocksDownloaded(_bitcoin, this.lastPercent, blocksLeft, this.lastBlockDate); } } }
@Override public void onBlocksDownloaded(final Peer peer, final Block block, final FilteredBlock filteredBlock, final int blocksLeft) { delayHandler.removeCallbacksAndMessages(null); final long now = System.currentTimeMillis(); if (now - lastMessageTime.get() > BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS) delayHandler.post(runnable); else delayHandler.postDelayed(runnable, BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS); }
@Override public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft){ logger.info("Block downloaded: "+blocksLeft); /* //this doesn't work Blocks blocks = Blocks.getInstance(); try { blocks.importBlock(block, blocks.blockStore.get(block.getHash()).getHeight()); } catch (BlockStoreException e) { } */ }
@Override public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) { super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft); //Log.i(TAG, "onBlocksDownloaded"); size+=block.getMessageSize(); double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft)); if ((int) pct != lastPercent) { lastPercent = (int) pct; walletObservable.setPercSync(lastPercent); walletObservable.notifyObservers(); } }
@Override public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) { super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft); //Log.i("onBlocksDownloaded", peer.toString()); }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { }
protected void onBlocksDownloadedEventListener(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) { this.blocksLeft.set(blocksLeft); }
@Override public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock fblock, int blocksLeft) { importer.saveBlock(block); }