当前位置: 首页>>代码示例>>Java>>正文


Java ScriptChunk.isOpCode方法代码示例

本文整理汇总了Java中com.google.bitcoin.script.ScriptChunk.isOpCode方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptChunk.isOpCode方法的具体用法?Java ScriptChunk.isOpCode怎么用?Java ScriptChunk.isOpCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.bitcoin.script.ScriptChunk的用法示例。


在下文中一共展示了ScriptChunk.isOpCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBloomFilter

import com.google.bitcoin.script.ScriptChunk; //导入方法依赖的package包/类
/**
 * Gets a bloom filter that contains all of the public keys from this wallet,
 * and which will provide the given false-positive rate if it has size elements.
 * Keep in mind that you will get 2 elements in the bloom filter for each key in the wallet.
 * 
 * This is used to generate a BloomFilter which can be #{link BloomFilter.merge}d with another.
 * It could also be used if you have a specific target for the filter's size.
 * 
 * See the docs for {@link BloomFilter(int, double)} for a brief explanation of anonymity when using bloom filters.
 */
@Override
public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) {
    BloomFilter filter = new BloomFilter(size, falsePositiveRate, nTweak);
    lock.lock();
    try {
        for (ECKey key : keychain) {
            filter.insert(key.getPubKey());
            filter.insert(key.getPubKeyHash());
        }

        for (Script script : watchedScripts) {
            for (ScriptChunk chunk : script.getChunks()) {
                // Only add long (at least 64 bit) data to the bloom filter.
                // If any long constants become popular in scripts, we will need logic
                // here to exclude them.
                if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) {
                    filter.insert(chunk.data);
                }
            }
        }
    } finally {
        lock.unlock();
    }
    for (Transaction tx : getTransactions(false)) {
        for (int i = 0; i < tx.getOutputs().size(); i++) {
            TransactionOutput out = tx.getOutputs().get(i);
            try {
                if (isTxOutputBloomFilterable(out)) {
                    TransactionOutPoint outPoint = new TransactionOutPoint(params, i, tx);
                    filter.insert(outPoint.bitcoinSerialize());
                }
            } catch (ScriptException e) {
                throw new RuntimeException(e); // If it is ours, we parsed the script correctly, so this shouldn't happen
            }
        }
    }

    return filter;
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:50,代码来源:Wallet.java


注:本文中的com.google.bitcoin.script.ScriptChunk.isOpCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。