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


Java PeerGroup类代码示例

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


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

示例1: resume

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public static void resume() {
    if (isInitialize == false)
        return;
    if (isPaused == false)
        return;
    isPaused = false;


    Log.d("BITCOINJ", "Create PeerGroup");
    peerGroup = new PeerGroup(netParams, blockChain);
    peerGroup.setUserAgent("PeerMonitor", "1.0");
    peerGroup.setMaxConnections(8);
    peerGroup.addPeerDiscovery(new DnsDiscovery(netParams));

    Log.d("BITCOINJ", "Start Asynchronous PeerGroup");
    peerGroup.start();
    Log.d("BITCOINJ", "Download Started");
    myDownload = new MyDownload();
    peerGroup.startBlockChainDownload(myDownload);

}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:22,代码来源:Bitcoin.java

示例2: isValidProof

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public boolean isValidProof(BlockChain bc, PeerGroup pg, NetworkParameters params) {
	if(!isValidPath()) {
		System.out.println("path is not valid, thus proof not valid, abort");
		return false;
	}
	if(!isValidGPTx()) {
		System.out.println("gptx is not valid, abort");
		return false;
	}
	if(!isNymNotSpend(bc)) {
		System.out.println("nym is not locked anymore, consider spent, abort");
		return false;
	}
	if(!isNymTxInBlockChain(params, bc, pg)) {
		System.out.println("nymtx is not in blockchain, consider proof invalid, abort");
		return false;
	}
	System.out.println("proof seems valid");
	return true;
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:21,代码来源:ProofMessage.java

示例3: getBlockchainService

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
@Bean
public BlockChainService getBlockchainService(final NetworkParameters params,
                                              final BlockChain blockChain,
                                              final PeerGroup peerGroup,
                                              final TransactionStateService transactionService,
                                              final WalletDbService walletService,
                                              final AccountDbService accountService,
                                              final BlockchainSettings settings
                                              ){

    final BitcoinjBlockchainServiceImpl blockChainService =
            new BitcoinjBlockchainServiceImpl(params, blockChain, peerGroup, transactionService, walletService, accountService, settings);

    blockChainService.init();
    return blockChainService;
}
 
开发者ID:yopeio,项目名称:payment-api,代码行数:17,代码来源:BitcoinjConfiguration.java

示例4: NameLookupLatestLevelDBTransactionCache

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public NameLookupLatestLevelDBTransactionCache (Context context, File directory, DBFactory dbFactory, BlockChain chain, BlockStore store, PeerGroup peerGroup) throws IOException {
    this.chain = chain;
    this.store = store;
    this.peerGroup = peerGroup;
    
    this.context = context;
    this.params = context.getParams();
    
    this.path = directory;
    Options options = new Options();
    options.createIfMissing();
    
    try {
        tryOpen(directory, dbFactory, options);
    } catch (IOException e) {
        dbFactory.repair(directory, options);
        tryOpen(directory, dbFactory, options);
    }
    
    chain.addNewBestBlockListener(Threading.SAME_THREAD, this);
    chain.addReorganizeListener(Threading.SAME_THREAD, this);
    chain.addTransactionReceivedListener(Threading.SAME_THREAD, this);
}
 
开发者ID:dogecoin,项目名称:libdohj,代码行数:24,代码来源:NameLookupLatestLevelDBTransactionCache.java

示例5: Authenticator

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
/**
 * Full instantiation
 * 
 * @param wallet
 * @param peerGroup
 * @param appParams
 * @throws IOException
 * @throws AccountWasNotFoundException 
 */
public Authenticator(Wallet wallet, PeerGroup peerGroup, BAApplicationParameters appParams) {
	super(Authenticator.class);
	try {
		init(appParams);
		if(mWalletOperation == null){
			mWalletOperation = new WalletOperation(wallet,peerGroup,appParams);
			
			initPendingRequests();
		}
		
		init2();	
	}
	catch (Exception e) { 
		e.printStackTrace(); 
		throw new RuntimeException("Could not instantiate Authenticator");
	}
		
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:28,代码来源:Authenticator.java

示例6: main

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    /*
     * This is just a test runner that will download blockchain till block
     * 390000 then exit.
     */
    FullPrunedBlockStore store = new LevelDBFullPrunedBlockStore(
            MainNetParams.get(), args[0], 1000, 100 * 1024 * 1024l,
            10 * 1024 * 1024, 100000, true, 390000);

    FullPrunedBlockChain vChain = new FullPrunedBlockChain(
            MainNetParams.get(), store);
    vChain.setRunScripts(false);

    PeerGroup vPeerGroup = new PeerGroup(MainNetParams.get(), vChain);
    vPeerGroup.setUseLocalhostPeerWhenPossible(true);
    vPeerGroup.addAddress(InetAddress.getLocalHost());

    vPeerGroup.start();
    vPeerGroup.downloadBlockChain();
}
 
开发者ID:HashEngineering,项目名称:dashj,代码行数:21,代码来源:LevelDB.java

示例7: main

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    BriefLogFormatter.init();
    PeerGroup peerGroup = new PeerGroup(PARAMS);
    peerGroup.setMaxConnections(32);
    peerGroup.addPeerDiscovery(new DnsDiscovery(PARAMS));
    peerGroup.addOnTransactionBroadcastListener(new OnTransactionBroadcastListener() {
        @Override
        public void onTransaction(Peer peer, Transaction tx) {
            Result result = DefaultRiskAnalysis.FACTORY.create(null, tx, NO_DEPS).analyze();
            incrementCounter(TOTAL_KEY);
            log.info("tx {} result {}", tx.getHash(), result);
            incrementCounter(result.name());
            if (result == Result.NON_STANDARD)
                incrementCounter(Result.NON_STANDARD + "-" + DefaultRiskAnalysis.isStandard(tx));
        }
    });
    peerGroup.start();

    while (true) {
        Thread.sleep(STATISTICS_FREQUENCY_MS);
        printCounters();
    }
}
 
开发者ID:HashEngineering,项目名称:dashj,代码行数:24,代码来源:WatchMempool.java

示例8: TransactionGenerator

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public TransactionGenerator(NetworkParameters params, PeerGroup pg, Wallet w, BlockChain bc) {
	this.params = params;
	this.pg = pg;
	this.w = w;
	this.bc = bc;
	
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:8,代码来源:TransactionGenerator.java

示例9: Mixer

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public Mixer(PTP ptp, BroadcastAnnouncement bca, ProofMessage pm, Wallet w, NetworkParameters params, PeerGroup pg, BlockChain bc) {
	this.ptp = ptp;
	this.bca = bca;
	this.mixPartnerAdress = new Identifier(bca.getOnionAdress() + ".onion");
	this.ownProof = pm;
	this.w = w;
	this.params = params;
	this.pg = pg;
	this.bc = bc;
	this.mfListeners = new ArrayList<MixFinishedEventListener>();
	this.lockTime = 0; 
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:13,代码来源:Mixer.java

示例10: ChallengeResponseVerifier

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public ChallengeResponseVerifier(PTP ptp, Wallet w, NetworkParameters params, PeerGroup pg, BlockChain bc) {
	this.ptp = ptp;
	this.w = w;
	this.params = params;
	this.pg = pg;
	this.bc = bc;
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:8,代码来源:ChallengeResponseVerifier.java

示例11: MixPartnerDiscovery

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
public MixPartnerDiscovery(NetworkParameters params, PeerGroup pg, BlockChain bc, Wallet wallet) {
	this.pg = pg;
	this.bc = bc;
	this.head = null;
	this.wallet = wallet;
	this.broadcasts = new ArrayList<Transaction>();
	this.listeners = new ArrayList<BroadcastAnnouncementChangeEventListener>();
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:9,代码来源:MixPartnerDiscovery.java

示例12: setUp

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    this.blockStore = new SPVBlockStore(this.params, new File("tbtc_blockstore"));
    final BlockChain chain = new BlockChain(new Context(this.params), this.blockStore);

    final PeerGroup peerGroup = new PeerGroup(this.params, chain);
    final BlockchainSettings settings = new BlockchainSettings(1, BigDecimal.ZERO, BigDecimal.TEN, "target", "central.wallet", "admin", "password");
    this.service = new BitcoinjBlockchainServiceImpl(this.params, chain, peerGroup, this.transactionService, this.walletService, this.accountService, settings);
    this.service.init();

    this.wallets.add(this.wallet);
    when(this.accountService.getByEmail("admin")).thenReturn(this.account);
    when(this.account.getWallets()).thenReturn(this.wallets);
    when(this.transactionService.getByReceiverHash(anyString())).thenReturn(this.transaction, this.transaction);
    when(this.wallet.toBuilder()).thenReturn(Wallet.builder());
    when(this.wallet.getContent()).thenAnswer(new Answer<String>() {
        @Override
        public String answer(final InvocationOnMock invocation) throws Throwable {
            counter ++;
            if (counter == 1) {
                return FileUtils.readFileToString(new File("src/test/resources/content.cnt"));
            }
            return FileUtils.readFileToString(new File("src/test/resources/content1.cnt"));
        }

    });
}
 
开发者ID:yopeio,项目名称:payment-api,代码行数:29,代码来源:BitcoinjBlockchainServiceImplTest.java

示例13: PeerGroupService

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
@Inject
public PeerGroupService(NetworkParameters params,
                   PeerDiscovery peerDiscovery) {
    this.netParams = params;
    this.peerGroup = new PeerGroup(params);
    peerGroup.setUserAgent(userAgentName, appVersion);
    peerGroup.addPeerDiscovery(peerDiscovery);
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:9,代码来源:PeerGroupService.java

示例14: run

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
@Override
public void run() {
    final WalletObservable walletObservable = ewApplication.getWalletObservable();

    if(walletObservable!=null) {
        Log.i(TAG, walletObservable.toString());
        final EWWalletService ewWalletService = ewApplication.getEwWalletService();
        if(ewWalletService.getBlockChain()!=null) {
            final int bestChainHeight = ewWalletService.getBlockChain().getBestChainHeight();
            Log.i(TAG, "blockchain height: " + bestChainHeight);
        }
        final PeerGroup peerGroup = ewWalletService.getPeerGroup();
        if(peerGroup !=null) {
            Log.i(TAG, "peerGroup is running? " + peerGroup.isRunning());
            Log.i(TAG, "peerGroup connected peers? " + peerGroup.numConnectedPeers());

        }
        final Wallet wallet = ewWalletService.getWallet();
        if(wallet !=null) {
            Log.i(TAG, "wallet height: " + wallet.getLastBlockSeenHeight());
            final Set<Transaction> transactions = wallet.getTransactions(true);
            final List<String> hashes=new LinkedList<>();
            for (Transaction tx : transactions) {
                hashes.add(tx.getHashAsString());
            }
            Log.i(TAG, "wallet txs: " + Joiner.on(",").join(hashes) );

        }
    } else {
        Log.i(TAG, "WalletObservable is null ()");
    }

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

示例15: start

import org.bitcoinj.core.PeerGroup; //导入依赖的package包/类
/**
 * Starts a bitcoin network peer and begins to listen
 *
 * @throws BlockStoreException
 */
public void start() throws BlockStoreException {
    BlockChain blockChain = new BlockChain(NET_PARAMS, new MemoryBlockStore(NET_PARAMS));
    PeerGroup peerGroup = new PeerGroup(NET_PARAMS, blockChain);
    peerGroup.addPeerDiscovery(new DnsDiscovery(NET_PARAMS));
    peerGroup.addEventListener(peerEventListener);
    peerGroup.startAsync();


}
 
开发者ID:lifeofreilly,项目名称:ostendo,代码行数:15,代码来源:PeerListener.java


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