Package org.bitcoinj.net.discovery
Class HttpDiscovery
- java.lang.Object
-
- org.bitcoinj.net.discovery.HttpDiscovery
-
- All Implemented Interfaces:
PeerDiscovery
public class HttpDiscovery extends java.lang.Object implements PeerDiscovery
A class that knows how to read signed sets of seeds over HTTP, using a simple protobuf based protocol. See the peerseeds.proto file for the definition, with a gzipped delimited SignedPeerSeeds being the root of the data. This is not currently in use by the Bitcoin community, but rather, is here for experimentation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpDiscovery.Details
-
Constructor Summary
Constructors Constructor Description HttpDiscovery(NetworkParameters params, java.net.URI uri, ECKey pubkey)
Constructs a discovery object that will read data from the given HTTP[S] URI and, if a public key is provided, will check the signature using that key.HttpDiscovery(NetworkParameters params, HttpDiscovery.Details details)
Constructs a discovery object that will read data from the given HTTP[S] URI and, if a public key is provided, will check the signature using that key.HttpDiscovery(NetworkParameters params, HttpDiscovery.Details details, okhttp3.OkHttpClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.net.InetSocketAddress>
getPeers(long services, long timeoutValue, java.util.concurrent.TimeUnit timeoutUnit)
Queries the addresses.java.util.List<java.net.InetSocketAddress>
protoToAddrs(PeerSeedProtos.SignedPeerSeeds proto)
void
shutdown()
Stops any discovery in progress when we want to shut down quickly.
-
-
-
Constructor Detail
-
HttpDiscovery
public HttpDiscovery(NetworkParameters params, java.net.URI uri, @Nullable ECKey pubkey)
Constructs a discovery object that will read data from the given HTTP[S] URI and, if a public key is provided, will check the signature using that key.
-
HttpDiscovery
public HttpDiscovery(NetworkParameters params, HttpDiscovery.Details details)
Constructs a discovery object that will read data from the given HTTP[S] URI and, if a public key is provided, will check the signature using that key.
-
HttpDiscovery
public HttpDiscovery(NetworkParameters params, HttpDiscovery.Details details, okhttp3.OkHttpClient client)
-
-
Method Detail
-
getPeers
public java.util.List<java.net.InetSocketAddress> getPeers(long services, long timeoutValue, java.util.concurrent.TimeUnit timeoutUnit) throws PeerDiscoveryException
Description copied from interface:PeerDiscovery
Queries the addresses. This method may block.- Specified by:
getPeers
in interfacePeerDiscovery
- Parameters:
services
- Required services as a bitmask, e.g.VersionMessage.NODE_NETWORK
.- Throws:
PeerDiscoveryException
-
protoToAddrs
public java.util.List<java.net.InetSocketAddress> protoToAddrs(PeerSeedProtos.SignedPeerSeeds proto) throws PeerDiscoveryException, com.google.protobuf.InvalidProtocolBufferException, SignatureDecodeException, java.security.SignatureException
- Throws:
PeerDiscoveryException
com.google.protobuf.InvalidProtocolBufferException
SignatureDecodeException
java.security.SignatureException
-
shutdown
public void shutdown()
Description copied from interface:PeerDiscovery
Stops any discovery in progress when we want to shut down quickly.- Specified by:
shutdown
in interfacePeerDiscovery
-
-