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


Java Peer类代码示例

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


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

示例1: onBlocksDownloaded

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, int blocksLeft) {
    if (caughtUp)
        return;

    if (blocksLeft == 0) {
        caughtUp = true;
        doneDownload();
        done.release();
    }

    if (blocksLeft < 0 || originalBlocksLeft <= 0)
        return;

    long now = System.currentTimeMillis();

    long msecsLeft = estimateComplete(now, blocksLeft);

    double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
    long delta = now - lastUpdateTime;
    if (delta >= 500) {
        progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000), msecsLeft);
        lastPercent = (int) pct;
        lastUpdateTime = now;
    }
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:27,代码来源:MyDownloadListener.java

示例2: redraw

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
private void redraw() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Button broadcastTransactionButton = (Button)findViewById(R.id.scanButton);
            ListView peerListView = (ListView)findViewById(R.id.peerList);
            List<Peer> connectedPeers = application.getPeerGroup().getConnectedPeers();
            application.getPeerListAdapter().replace(connectedPeers);
            // Enable button if we're sufficiently connected
            if(application.getPeerGroup().numConnectedPeers() >= 3) {
                broadcastTransactionButton.setEnabled(true);
            } else {
                broadcastTransactionButton.setEnabled(false);
            }
        }
    });
}
 
开发者ID:hank,项目名称:armorycompanion,代码行数:18,代码来源:PeerActivity.java

示例3: getView

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if(convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.peer_row, parent, false);
    }
    Log.i("Adapter", "In getView, position " + position);
    Peer peer = values.get(position);

    TextView peerName = (TextView) convertView.findViewById(R.id.peerName);
    TextView peerAddress = (TextView) convertView.findViewById(R.id.peerAddress);
    peerName.setText(peer.getPeerVersionMessage().subVer);
    peerAddress.setText(peer.getPeerVersionMessage().theirAddr.toString());
    return convertView;
}
 
开发者ID:hank,项目名称:armorycompanion,代码行数:17,代码来源:PeerListAdapter.java

示例4: onBlocksDownloaded

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
public void onBlocksDownloaded(Peer peer, Block block, int blocksLeft) {
    if (caughtUp)
        return;

    if (blocksLeft == 0) {
        caughtUp = true;
        doneDownload();
        done.release();
    }

    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;
    }
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:20,代码来源:MyDownloadListener.java

示例5: lookupReverseDNS

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
private void lookupReverseDNS(final Peer peer) {
    new Thread() {
        @Override
        public void run() {
            // This can take a looooong time.
            String reverseDns = peer.getAddress().getAddr().getCanonicalHostName();
            synchronized (reverseDnsLookups) {
                reverseDnsLookups.put(peer, reverseDns);
            }
            refreshUI();
        }
    }.start();
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:14,代码来源:PeerMonitor.java

示例6: getAddressForPeer

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
private Object getAddressForPeer(Peer peer) {
    String s;
    synchronized (reverseDnsLookups) {
        s = reverseDnsLookups.get(peer);
    }
    if (s != null)
        return s;
    else
        return peer.getAddress().getAddr().getHostAddress();
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:11,代码来源:PeerMonitor.java

示例7: onChainDownloadStarted

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    startDownload(blocksLeft);
    originalBlocksLeft = blocksLeft;
    if (blocksLeft == 0) {
        doneDownload();
        done.release();
    }
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:10,代码来源:MyDownloadListener.java

示例8: onBlocksDownloaded

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, 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) {
	}
	*/
}
 
开发者ID:newbiecoin,项目名称:newbiecoinj,代码行数:13,代码来源:NewbiecoinPeerEventListener.java

示例9: initSingletons

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
protected void initSingletons()
{
    // Initialize the instance of MySingleton
    peerGroup = new PeerGroup(Constants.NETWORK_PARAMETERS);
    peerGroup.setMaxConnections(5);
    peerGroup.setUserAgent("ArmoryCompanion Android", Constants.VERSION, "Relaying txs like a boss");
    peerGroup.addPeerDiscovery(new DnsDiscovery(Constants.NETWORK_PARAMETERS));
    peerGroup.start();
    List<Peer> connectedPeers = peerGroup.getConnectedPeers();
    peerListAdapter = new PeerListAdapter(this, connectedPeers);
}
 
开发者ID:hank,项目名称:armorycompanion,代码行数:12,代码来源:ArmoryCompanionApplication.java

示例10: onChainDownloadStarted

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    Log.d(TAG, String.format("onChainDownloadStarted | peer: %s, blocksLeft: %s", peer.toString(), blocksLeft));
    startDownload(blocksLeft);
    originalBlocksLeft = blocksLeft;
    if (blocksLeft == 0) {
        doneDownload();
        done.release();
    }
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:10,代码来源:MyDownloadListener.java

示例11: onBlocksDownloaded

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(final Peer peer, final Block block, final int blocksLeft)
{
	bestChainHeightEver = Math.max(bestChainHeightEver, blockChain.getChainHead().getHeight());

	delayHandler.removeCallbacksAndMessages(null);

	final long now = System.currentTimeMillis();

	if (now - lastMessageTime.get() > Constants.BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS)
		delayHandler.post(runnable);
	else
		delayHandler.postDelayed(runnable, Constants.BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS);
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:15,代码来源:BlockchainServiceImpl.java

示例12: getConnectedPeers

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public List<Peer> getConnectedPeers()
{
	if (peerGroup != null)
		return peerGroup.getConnectedPeers();
	else
		return null;
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:9,代码来源:BlockchainServiceImpl.java

示例13: onResume

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public void onResume()
{
	super.onResume();

	handler.postDelayed(new Runnable()
	{
		@Override
		public void run()
		{
			adapter.notifyDataSetChanged();

			final Loader<String> loader = loaderManager.getLoader(ID_REVERSE_DNS_LOADER);
			final boolean loaderRunning = loader != null && loader.isStarted();

			if (!loaderRunning)
			{
				for (int i = 0; i < adapter.getCount(); i++)
				{
					final Peer peer = adapter.getItem(i);
					final InetAddress address = peer.getAddress().getAddr();

					if (!hostnames.containsKey(address))
					{
						final Bundle args = new Bundle();
						args.putSerializable("address", address);
						loaderManager.initLoader(ID_REVERSE_DNS_LOADER, args, reverseDnsLoaderCallbacks).forceLoad();

						break;
					}
				}
			}

			handler.postDelayed(this, REFRESH_MS);
		}
	}, REFRESH_MS);
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:38,代码来源:PeerListFragment.java

示例14: onLoadFinished

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public void onLoadFinished(final Loader<List<Peer>> loader, final List<Peer> peers)
{
	adapter.clear();

	if (peers != null)
		for (final Peer peer : peers)
			adapter.add(peer);
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:10,代码来源:PeerListFragment.java

示例15: onPreMessageReceived

import com.google.bitcoin.core.Peer; //导入依赖的package包/类
@Override
public Message onPreMessageReceived(Peer peer, Message m) {
	if (m instanceof Pong) {
		// nothing
	} else if (m instanceof InventoryMessage) {
		InventoryMessage inv = (InventoryMessage) m;
		log.info("[MESSAGE INV] size={}\nitem={}",
				inv.getItems().size(),
				Joiner.on(",").join(Lists.transform(inv.getItems(), FunInvItemToString)));
	} else {
		log.info("[MESSAGE] = {}", m);
	}
	return super.onPreMessageReceived(peer, m);
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:15,代码来源:DebugPeerEventListener.java


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