Java 类org.bitcoinj.core.FilteredBlock 实例源码

项目:BitcoinBlockExplorer    文件:FragmentBlocks.java   
@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();
    }
}
项目:xwallet    文件:DownloadProgressListener.java   
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;
            }

        }
    }
}
项目:bitnym    文件:MixPartnerDiscovery.java   
@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();
        }
    }
}
项目:okwallet    文件:Wallet.java   
/**
 * 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();
    }
}
项目:okwallet    文件:DownloadProgressTracker.java   
@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;
    }
}
项目:cryptwallet    文件:Wallet.java   
/**
 * 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();
    }
}
项目:cryptwallet    文件:DownloadProgressTracker.java   
@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;
    }
}
项目:dashj    文件:DownloadProgressTracker.java   
@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;
    }
}
项目:bitcoinj    文件:Wallet.java   
/**
 * 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();
    }
}
项目:bitcoinj    文件:DownloadProgressTracker.java   
@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;
    }
}
项目:xwallet    文件:BitcoinRecoverAction.java   
/**
 *
 * @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);
        }
    }
}
项目:xwallet    文件:BitcoinSetupAction.java   
/**
 *
 * @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);
        }
    }
}
项目:okwallet    文件:BlockchainServiceImpl.java   
@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);
}
项目:javatool    文件:PPkPeerEventListener.java   
@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) {
  }
  */
}
项目:ombuds-android    文件:BlockchainServiceImpl.java   
@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);
}
项目:EternityWallAndroid    文件:MyDownloadListener.java   
@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();
    }
}
项目:BitcoinBlockExplorer    文件:Bitcoin.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
    super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);
    //Log.i("onBlocksDownloaded", peer.toString());
}
项目:okwallet    文件:AbstractPeerEventListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}
项目:cryptwallet    文件:AbstractPeerEventListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}
项目:cate    文件:Network.java   
protected void onBlocksDownloadedEventListener(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
    this.blocksLeft.set(blocksLeft);
}
项目:dashj    文件:AbstractPeerEventListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}
项目:jelectrum    文件:ImportEventListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock fblock, int blocksLeft)
{
    importer.saveBlock(block);

}
项目:bitcoinj    文件:AbstractPeerEventListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}