本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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();
}