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


Java PeerAddress类代码示例

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


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

示例1: startDownload

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
public void startDownload() {
    BriefLogFormatter.init();
    String filePrefix = "voting-wallet";
    File walletFile = new File(Environment.getExternalStorageDirectory() + "/" + Util.FOLDER_DIGITAL_VOTING_PASS);
    if (!walletFile.exists()) {
        walletFile.mkdirs();
    }
    kit = new WalletAppKit(params, walletFile, filePrefix);

    //set the observer
    kit.setDownloadListener(progressTracker);

    kit.setBlockingStartup(false);

    PeerAddress peer = new PeerAddress(params, peeraddr);
    kit.setPeerNodes(peer);
    kit.startAsync();
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:19,代码来源:BlockChain.java

示例2: writeConfidence

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
private static void writeConfidence(Protos.Transaction.Builder txBuilder,
                                        TransactionConfidence confidence,
                                        Protos.TransactionConfidence.Builder confidenceBuilder) {
        synchronized (confidence) {
            confidenceBuilder.setType(Protos.TransactionConfidence.Type.valueOf(confidence.getConfidenceType().getValue()));
            if (confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) {
                confidenceBuilder.setAppearedAtHeight(confidence.getAppearedAtChainHeight());
                confidenceBuilder.setDepth(confidence.getDepthInBlocks());
            }
            // TODO deprecate overriding transactions
//            if (confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.DEAD) {
//                // Copy in the overriding transaction, if available.
//                // (A dead coinbase transaction has no overriding transaction).
//                if (confidence.getOverridingTransaction() != null) {
//                    Sha256Hash overridingHash = confidence.getOverridingTransaction().getHash();
//                    confidenceBuilder.setOverridingTransaction(hashToByteString(overridingHash));
//                }
//            }
            TransactionConfidence.Source source = confidence.getSource();
            switch (source) {
                case SELF: confidenceBuilder.setSource(Protos.TransactionConfidence.Source.SOURCE_SELF); break;
                case NETWORK: confidenceBuilder.setSource(Protos.TransactionConfidence.Source.SOURCE_NETWORK); break;
                case UNKNOWN:
                    // Fall through.
                default:
                    confidenceBuilder.setSource(Protos.TransactionConfidence.Source.SOURCE_UNKNOWN); break;
            }
        }

        for (ListIterator<PeerAddress> it = confidence.getBroadcastBy(); it.hasNext();) {
            PeerAddress address = it.next();
            Protos.PeerAddress proto = Protos.PeerAddress.newBuilder()
                    .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress()))
                    .setPort(address.getPort())
                    .setServices(address.getServices().longValue())
                    .build();
            confidenceBuilder.addBroadcastBy(proto);
        }
        txBuilder.setConfidence(confidenceBuilder);
    }
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:41,代码来源:WalletPocketProtobufSerializer.java

示例3: MAIN_NET

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
public static PeerAddress[] MAIN_NET() {
	PeerAddress[] ret = new PeerAddress[MAIN_NET.length];
	
	for(int i=0; i< MAIN_NET.length; i++)
		try {
			ret[i] = new PeerAddress(InetAddress.getByName(MAIN_NET[i]));
		} catch (UnknownHostException e) { e.printStackTrace(); }
	
	return ret;
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:11,代码来源:TrustedPeerNodes.java

示例4: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {
	UniquidWatchingNodeImpl.this.uniquidNodeEventService.onPeersDiscovered(peerAddresses);
}
 
开发者ID:uniquid,项目名称:uidcore-java,代码行数:5,代码来源:UniquidWatchingNodeImpl.java

示例5: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
public void onPeersDiscovered(final Set<PeerAddress> peerAddresses) {
		executorService.submit(new Runnable() {
		
		@Override
		public void run() {
			
			for (UniquidNodeEventListener listener : observers) {
				
				listener.onPeersDiscovered(peerAddresses);
				
			}
			
		}
		
	});	
	
}
 
开发者ID:uniquid,项目名称:uidcore-java,代码行数:18,代码来源:UniquidNodeEventService.java

示例6: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {
	// NOTHING TO DO		
}
 
开发者ID:uniquid,项目名称:uidcore-java,代码行数:5,代码来源:EmptyUniquidNodeEventListener.java

示例7: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {
	// TODO Auto-generated method stub
	
}
 
开发者ID:uniquid,项目名称:uidcore-java,代码行数:6,代码来源:UniquidNodeEventServiceTests.java

示例8: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
/**
 *
 * @param set
 */
@Override
public void onPeersDiscovered(Set<PeerAddress> set) {
    System.out.println("onPeersDiscovered(), peers: " + set);
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:9,代码来源:XWalletPeerListener.java

示例9: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:AbstractPeerEventListener.java

示例10: readConfidence

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
private void readConfidence(Transaction tx, Protos.TransactionConfidence confidenceProto,
                                TransactionConfidence confidence) throws UnreadableWalletException {
        // We are lenient here because tx confidence is not an essential part of the wallet.
        // If the tx has an unknown type of confidence, ignore.
        if (!confidenceProto.hasType()) {
            log.warn("Unknown confidence type for tx {}", tx.getHashAsString());
            return;
        }
        ConfidenceType confidenceType;
        switch (confidenceProto.getType()) {
            case BUILDING: confidenceType = ConfidenceType.BUILDING; break;
            case DEAD: confidenceType = ConfidenceType.DEAD; break;
            case PENDING: confidenceType = ConfidenceType.PENDING; break;
            case UNKNOWN:
                // Fall through.
            default:
                confidenceType = ConfidenceType.UNKNOWN; break;
        }
        confidence.setConfidenceType(confidenceType);
        if (confidenceProto.hasAppearedAtHeight()) {
            if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
                log.warn("Have appearedAtHeight but not BUILDING for tx {}", tx.getHashAsString());
                return;
            }
            confidence.setAppearedAtChainHeight(confidenceProto.getAppearedAtHeight());
        }
        if (confidenceProto.hasDepth()) {
            if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
                log.warn("Have depth but not BUILDING for tx {}", tx.getHashAsString());
                return;
            }
            confidence.setDepthInBlocks(confidenceProto.getDepth());
        }
        // TODO deprecate overriding transactions
//        if (confidenceProto.hasOverridingTransaction()) {
//            if (confidence.getConfidenceType() != ConfidenceType.DEAD) {
//                log.warn("Have overridingTransaction but not OVERRIDDEN for tx {}", tx.getHashAsString());
//                return;
//            }
//            Transaction overridingTransaction =
//                    txMap.get(confidenceProto.getOverridingTransaction());
//            if (overridingTransaction == null) {
//                log.warn("Have overridingTransaction that is not in wallet for tx {}", tx.getHashAsString());
//                return;
//            }
//            confidence.setOverridingTransaction(overridingTransaction);
//        }
        for (Protos.PeerAddress proto : confidenceProto.getBroadcastByList()) {
            InetAddress ip;
            try {
                ip = InetAddress.getByAddress(proto.getIpAddress().toByteArray());
            } catch (UnknownHostException e) {
                throw new UnreadableWalletException("Peer IP address does not have the right length", e);
            }
            int port = proto.getPort();
            PeerAddress address = new PeerAddress(ip, port);
            address.setServices(BigInteger.valueOf(proto.getServices()));
            confidence.markBroadcastBy(address);
        }
        switch (confidenceProto.getSource()) {
            case SOURCE_SELF: confidence.setSource(TransactionConfidence.Source.SELF); break;
            case SOURCE_NETWORK: confidence.setSource(TransactionConfidence.Source.NETWORK); break;
            case SOURCE_UNKNOWN:
                // Fall through.
            default: confidence.setSource(TransactionConfidence.Source.UNKNOWN); break;
        }
    }
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:68,代码来源:WalletPocketProtobufSerializer.java

示例11: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses){
      logger.info("Peers discovered");    
  }
 
开发者ID:ppkpub,项目名称:javatool,代码行数:5,代码来源:PPkPeerEventListener.java

示例12: testWalletApp

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Test
public void testWalletApp() throws UnknownHostException {


    WalletAppKit kit = new WalletAppKit(MainNetParams.get(), new File("/tmp"), "" + System.currentTimeMillis()) {
        @Override
        protected void onSetupCompleted() {
            // This is called in a background thread after startAndWait is called, as setting up various objects
            // can do disk and network IO that may cause UI jank/stuttering in wallet apps if it were to be done
            // on the main thread.
            System.out.println("keyChainSize=" + wallet().getKeychainSize());

            if (wallet().getKeychainSize() < 1) {
                System.out.println("<1");
                wallet().importKey(new ECKey());
            } else {
                System.out.println(">1");
            }
        }
    };


    kit.setPeerNodes(new PeerAddress(InetAddress.getByName("10.106.137.73")));


    Service service = kit.startAsync();

    service.awaitRunning();
    //kit.peerGroup().addPeerFilterProvider(new EWFilterProvider());
    EWChainListener listener = new EWChainListener();
    kit.chain().addListener(listener);

    Address address = kit.wallet().freshReceiveAddress();
    kit.wallet().addEventListener(new AbstractWalletEventListener() {
        @Override
        public void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
            System.out.println("onCoinsReceived");

            Coin value = tx.getValueSentToMe(w);
            System.out.println("Received tx for " + value.toFriendlyString() + ": " + tx);
            System.out.println("Transaction will be forwarded after it confirms.");
            // Wait until it's made it into the block chain (may run immediately if it's already there).
            //
            // For this dummy app of course, we could just forward the unconfirmed transaction. If it were
            // to be double spent, no harm done. Wallet.allowSpendingUnconfirmedTransactions() would have to
            // be called in onSetupCompleted() above. But we don't do that here to demonstrate the more common
            // case of waiting for a block.
            /*
            Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<Transaction>() {
                @Override
                public void onSuccess(Transaction result) {
                    // "result" here is the same as "tx" above, but we use it anyway for clarity.
                    //forwardCoins(result);
                }

                @Override
                public void onFailure(Throwable t) {
                }
            });
            */
        }
    });
    System.out.println("address= " + address.toString());
    System.out.println("counter=" + listener.counter);

    service.awaitTerminated();

}
 
开发者ID:RCasatta,项目名称:EternityWallAndroid,代码行数:69,代码来源:WalletAppKitTest.java

示例13: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
/**
    * Called when peers are discovered, this happens at startup of {@link PeerGroup} or if we run out of
    * suitable {@link Peer}s to connect to.
    *
    * @param peerAddresses the set of discovered {@link PeerAddress}
    */
public void onPeersDiscovered(Set<PeerAddress> peerAddresses);
 
开发者ID:uniquid,项目名称:uidcore-java,代码行数:8,代码来源:UniquidNodeEventListener.java

示例14: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
/**
 * <p>Called when peers are discovered, this happens at startup of {@link PeerGroup} or if we run out of
 * suitable {@link Peer}s to connect to.</p>
 *
 * @param peerAddresses the set of discovered {@link PeerAddress}es
 */
void onPeersDiscovered(Set<PeerAddress> peerAddresses);
 
开发者ID:guodroid,项目名称:okwallet,代码行数:8,代码来源:PeerDiscoveredEventListener.java

示例15: onPeersDiscovered

import org.bitcoinj.core.PeerAddress; //导入依赖的package包/类
@Override
public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {

}
 
开发者ID:RCasatta,项目名称:EternityWallAndroid,代码行数:5,代码来源:MyDownloadListener.java


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