• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VersionMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onCreate

import com.google.bitcoin.core.VersionMessage; //导入依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);

	addPreferencesFromResource(R.xml.about);

	final ActionBar actionBar = getSupportActionBar();
	actionBar.setDisplayHomeAsUpEnabled(true);

	findPreference(KEY_ABOUT_VERSION).setSummary(((WalletApplication) getApplication()).packageInfo().versionName);
	findPreference(KEY_ABOUT_LICENSE).setSummary(Constants.LICENSE_URL);
	findPreference(KEY_ABOUT_SOURCE).setSummary(Constants.FORKED_FROM_SOURCE +Constants.SOURCE_URL);

	findPreference(KEY_ABOUT_MARKET_PUBLISHER).setSummary(Constants.MARKET_PUBLISHER_URL);

	findPreference(KEY_ABOUT_CREDITS_BITCOINJ).setTitle(getString(R.string.about_credits_bitcoinj_title, VersionMessage.BITCOINJ_VERSION));
	findPreference(KEY_ABOUT_CREDITS_BITCOINJ).setSummary("based on bitcoinj 0.11\n"+Constants.CREDITS_BITCOINJ_URL);
	findPreference(KEY_ABOUT_CREDITS_ZXING).setSummary(Constants.CREDITS_ZXING_URL);

	//findPreference(KEY_ABOUT_CREDITS_ICON).setSummary(Constants.CREDITS_ICON_URL);
	findPreference(KEY_ABOUT_MARKET_APP).setSummary(String.format(Constants.MARKET_APP_URL, getPackageName()));
	//findPreference(KEY_ABOUT_MARKET_PUBLISHER).setSummary(Constants.MARKET_PUBLISHER_URL);
       findPreference(KEY_ABOUT_CREDITS_WEBSITE).setSummary(Constants.CREDITS_WEBSITE_URL);
       findPreference(KEY_ABOUT_CREDITS_FORUM).setSummary(Constants.CREDITS_FORUM_URL);

}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:28,代码来源:AboutActivity.java


示例2: onCreate

import com.google.bitcoin.core.VersionMessage; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);

	adapter = new ArrayAdapter<Peer>(activity, 0)
	{
		@Override
		public View getView(final int position, View row, final ViewGroup parent)
		{
			if (row == null)
				row = getLayoutInflater(null).inflate(R.layout.peer_list_row, null);

			final Peer peer = getItem(position);
			final VersionMessage versionMessage = peer.getPeerVersionMessage();
			final boolean isDownloading = peer.getDownloadData();

			final TextView rowIp = (TextView) row.findViewById(R.id.peer_list_row_ip);
			final InetAddress address = peer.getAddress().getAddr();
			final String hostname = hostnames.get(address);
			rowIp.setText(/*address.toString()*/hostname != null ? hostname : address.getHostAddress());

			final TextView rowHeight = (TextView) row.findViewById(R.id.peer_list_row_height);
			final long bestHeight = peer.getBestHeight();
			rowHeight.setText(bestHeight > 0 ? bestHeight + " blocks" : null);
			rowHeight.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

			final TextView rowVersion = (TextView) row.findViewById(R.id.peer_list_row_version);
			rowVersion.setText(versionMessage.subVer);
			rowVersion.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

			final TextView rowProtocol = (TextView) row.findViewById(R.id.peer_list_row_protocol);
			rowProtocol.setText("protocol: " + versionMessage.clientVersion);
			rowProtocol.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

			final TextView rowPing = (TextView) row.findViewById(R.id.peer_list_row_ping);
			final long pingTime = peer.getPingTime();
			rowPing.setText(pingTime < Long.MAX_VALUE ? getString(R.string.peer_list_row_ping_time, pingTime) : null);
			rowPing.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

			return row;
		}

		@Override
		public boolean isEnabled(final int position)
		{
			return false;
		}
	};
	setListAdapter(adapter);
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:52,代码来源:PeerListFragment.java


示例3: main

import com.google.bitcoin.core.VersionMessage; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    System.out.println("=== DNS ===");
    printDNS();
    System.out.println("=== Version/chain heights ===");

    ArrayList<InetAddress> addrs = new ArrayList<InetAddress>();
    for (InetSocketAddress peer : dnsPeers) addrs.add(peer.getAddress());
    System.out.println("Scanning " + addrs.size() + " peers:");

    final NetworkParameters params = MainNetParams.get();
    final Object lock = new Object();
    final long[] bestHeight = new long[1];

    List<ListenableFuture<TCPNetworkConnection>> futures = Lists.newArrayList();
    for (final InetAddress addr : addrs) {
        final ListenableFuture<TCPNetworkConnection> future =
                TCPNetworkConnection.connectTo(params, new InetSocketAddress(addr, params.getPort()), 1000 /* timeout */, null);
        futures.add(future);
        // Once the connection has completed version handshaking ...
        Futures.addCallback(future, new FutureCallback<TCPNetworkConnection>() {
            public void onSuccess(TCPNetworkConnection conn) {
                // Check the chain height it claims to have.
                VersionMessage ver = conn.getVersionMessage();
                long nodeHeight = ver.bestHeight;
                synchronized (lock) {
                    long diff = bestHeight[0] - nodeHeight;
                    if (diff > 0) {
                        System.out.println("Node is behind by " + diff + " blocks: " + addr);
                    } else if (diff == 0) {
                        System.out.println("Node " + addr + " has " + nodeHeight + " blocks");
                        bestHeight[0] = nodeHeight;
                    } else if (diff < 0) {
                        System.out.println("Node is ahead by " + Math.abs(diff) + " blocks: " + addr);
                        bestHeight[0] = nodeHeight;
                    }
                }
                conn.close();
            }

            public void onFailure(Throwable throwable) {
                System.out.println("Failed to talk to " + addr + ": " + throwable.getMessage());
            }
        });
    }
    // Wait for every tried connection to finish.
    Futures.successfulAsList(futures).get();
}
 
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:49,代码来源:PrintPeers.java


示例4: main

import com.google.bitcoin.core.VersionMessage; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    BriefLogFormatter.init();
    System.out.println("=== DNS ===");
    printDNS();
    System.out.println("=== Version/chain heights ===");

    ArrayList<InetAddress> addrs = new ArrayList<InetAddress>();
    for (InetSocketAddress peer : dnsPeers) addrs.add(peer.getAddress());
    System.out.println("Scanning " + addrs.size() + " peers:");

    final NetworkParameters params = MainNetParams.get();
    final Object lock = new Object();
    final long[] bestHeight = new long[1];

    List<ListenableFuture<TCPNetworkConnection>> futures = Lists.newArrayList();
    for (final InetAddress addr : addrs) {
        final ListenableFuture<TCPNetworkConnection> future =
                TCPNetworkConnection.connectTo(params, new InetSocketAddress(addr, params.getPort()), 1000 /* timeout */);
        futures.add(future);
        // Once the connection has completed version handshaking ...
        Futures.addCallback(future, new FutureCallback<TCPNetworkConnection>() {
            public void onSuccess(TCPNetworkConnection conn) {
                // Check the chain height it claims to have.
                VersionMessage ver = conn.getVersionMessage();
                long nodeHeight = ver.bestHeight;
                synchronized (lock) {
                    long diff = bestHeight[0] - nodeHeight;
                    if (diff > 0) {
                        System.out.println("Node is behind by " + diff + " blocks: " + addr);
                    } else if (diff == 0) {
                        System.out.println("Node " + addr + " has " + nodeHeight + " blocks");
                        bestHeight[0] = nodeHeight;
                    } else if (diff < 0) {
                        System.out.println("Node is ahead by " + Math.abs(diff) + " blocks: " + addr);
                        bestHeight[0] = nodeHeight;
                    }
                }
                conn.close();
            }

            public void onFailure(Throwable throwable) {
                System.out.println("Failed to talk to " + addr + ": " + throwable.getMessage());
            }
        });
    }
    // Wait for every tried connection to finish.
    Futures.successfulAsList(futures).get();
}
 
开发者ID:praus,项目名称:multicoinj,代码行数:49,代码来源:PrintPeers.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GroupPrincipalCallback类代码示例发布时间:2022-05-22
下一篇:
Java Response类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap