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


Java BlockChain.NewBlockType方法代码示例

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


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

示例1: notifyTransactionIsInBlock

import org.bitcoinj.core.BlockChain; //导入方法依赖的package包/类
/**
 * Called by the {@link BlockChain} when we receive a new filtered block that contains a transactions previously
 * received by a call to {@link #receivePending}.<p>
 *
 * This is necessary for the internal book-keeping Wallet does. When a transaction is received that sends us
 * coins it is added to a pool so we can use it later to create spends. When a transaction is received that
 * consumes outputs they are marked as spent so they won't be used in future.<p>
 *
 * A transaction that spends our own coins can be received either because a spend we created was accepted by the
 * network and thus made it into a block, or because our keys are being shared between multiple instances and
 * some other node spent the coins instead. We still have to know about that to avoid accidentally trying to
 * double spend.<p>
 *
 * A transaction may be received multiple times if is included into blocks in parallel chains. The blockType
 * parameter describes whether the containing block is on the main/best chain or whether it's on a presently
 * inactive side chain. We must still record these transactions and the blocks they appear in because a future
 * block might change which chain is best causing a reorganize. A re-org can totally change our balance!
 */
@Override
public boolean notifyTransactionIsInBlock(Sha256Hash txHash, StoredBlock block,
                                          BlockChain.NewBlockType blockType,
                                          int relativityOffset) throws VerificationException {
    lock.lock();
    try {
        Transaction tx = transactions.get(txHash);
        if (tx == null) {
            tx = riskDropped.get(txHash);
            if (tx != null) {
                // If this happens our risk analysis is probably wrong and should be improved.
                log.info("Risk analysis dropped tx {} but was included in block anyway", tx.getHash());
            } else {
                // False positive that was broadcast to us and ignored by us because it was irrelevant to our keys.
                return false;
            }
        }
        receive(tx, block, blockType, relativityOffset);
        return true;
    } finally {
        lock.unlock();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:42,代码来源:Wallet.java

示例2: receiveFromBlock

import org.bitcoinj.core.BlockChain; //导入方法依赖的package包/类
/**
 * Called by the {@link BlockChain} when we receive a new block that sends coins to one of our addresses or
 * spends coins from one of our addresses (note that a single transaction can do both).<p>
 *
 * This is necessary for the internal book-keeping Wallet does. When a transaction is received that sends us
 * coins it is added to a pool so we can use it later to create spends. When a transaction is received that
 * consumes outputs they are marked as spent so they won't be used in future.<p>
 *
 * A transaction that spends our own coins can be received either because a spend we created was accepted by the
 * network and thus made it into a block, or because our keys are being shared between multiple instances and
 * some other node spent the coins instead. We still have to know about that to avoid accidentally trying to
 * double spend.<p>
 *
 * A transaction may be received multiple times if is included into blocks in parallel chains. The blockType
 * parameter describes whether the containing block is on the main/best chain or whether it's on a presently
 * inactive side chain. We must still record these transactions and the blocks they appear in because a future
 * block might change which chain is best causing a reorganize. A re-org can totally change our balance!
 */
@Override
public void receiveFromBlock(Transaction tx, StoredBlock block,
                             BlockChain.NewBlockType blockType,
                             int relativityOffset) throws VerificationException {
    lock.lock();
    try {
        if (!isTransactionRelevant(tx))
            return;
        receive(tx, block, blockType, relativityOffset);
    } finally {
        lock.unlock();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:32,代码来源:Wallet.java

示例3: receiveFromBlock

import org.bitcoinj.core.BlockChain; //导入方法依赖的package包/类
/**
 * <p>Called by the {@link BlockChain} when we receive a new block that contains a relevant transaction.</p>
 *
 * <p>A transaction may be received multiple times if is included into blocks in parallel chains. The blockType
 * parameter describes whether the containing block is on the main/best chain or whether it's on a presently
 * inactive side chain.</p>
 *
 * <p>The relativityOffset parameter is an arbitrary number used to establish an ordering between transactions
 * within the same block. In the case where full blocks are being downloaded, it is simply the index of the
 * transaction within that block. When Bloom filtering is in use, we don't find out the exact offset into a block
 * that a transaction occurred at, so the relativity count is not reflective of anything in an absolute sense but
 * rather exists only to order the transaction relative to the others.</p>
 */
void receiveFromBlock(Transaction tx, StoredBlock block,
                      BlockChain.NewBlockType blockType,
                      int relativityOffset) throws VerificationException;
 
开发者ID:guodroid,项目名称:okwallet,代码行数:17,代码来源:TransactionReceivedInBlockListener.java

示例4: notifyTransactionIsInBlock

import org.bitcoinj.core.BlockChain; //导入方法依赖的package包/类
/**
 * <p>Called by the {@link BlockChain} when we receive a new {@link FilteredBlock} that contains the given
 * transaction hash in its merkle tree.</p>
 *
 * <p>A transaction may be received multiple times if is included into blocks in parallel chains. The blockType
 * parameter describes whether the containing block is on the main/best chain or whether it's on a presently
 * inactive side chain.</p>
 *
 * <p>The relativityOffset parameter in this case is an arbitrary (meaningless) number, that is useful only when
 * compared to the relativity count of another transaction received inside the same block. It is used to establish
 * an ordering of transactions relative to one another.</p>
 *
 * <p>This method should return false if the given tx hash isn't known about, e.g. because the the transaction was
 * a Bloom false positive. If it was known about and stored, it should return true. The caller may need to know
 * this to calculate the effective FP rate.</p>
 *
 * @return whether the transaction is known about i.e. was considered relevant previously.
 */
boolean notifyTransactionIsInBlock(Sha256Hash txHash, StoredBlock block,
                                   BlockChain.NewBlockType blockType,
                                   int relativityOffset) throws VerificationException;
 
开发者ID:guodroid,项目名称:okwallet,代码行数:22,代码来源:TransactionReceivedInBlockListener.java


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