public class PeerAddress extends ChildMessage
A PeerAddress holds an IP address and port number representing the network location of a peer in the Bitcoin P2P network. It exists primarily for serialization purposes.
Instances of this class are not safe for use by multiple threads.
parent
cursor, length, MAX_SIZE, offset, params, payload, protocolVersion, recached, serializer, UNKNOWN_LENGTH
Constructor and Description |
---|
PeerAddress(NetworkParameters params,
byte[] payload,
int offset,
int protocolVersion)
Construct a peer address from a serialized payload.
|
PeerAddress(NetworkParameters params,
byte[] payload,
int offset,
int protocolVersion,
Message parent,
MessageSerializer serializer)
Construct a peer address from a serialized payload.
|
PeerAddress(NetworkParameters params,
java.net.InetAddress addr)
Constructs a peer address from the given IP address.
|
PeerAddress(NetworkParameters params,
java.net.InetAddress addr,
int port)
Constructs a peer address from the given IP address and port.
|
PeerAddress(NetworkParameters params,
java.net.InetAddress addr,
int port,
int protocolVersion,
java.math.BigInteger services)
Construct a peer address from a memorized or hardcoded address.
|
PeerAddress(NetworkParameters params,
java.net.InetSocketAddress addr)
Constructs a peer address from an
InetSocketAddress . |
PeerAddress(NetworkParameters params,
java.lang.String hostname,
int port)
Constructs a peer address from a stringified hostname+port.
|
Modifier and Type | Method and Description |
---|---|
protected void |
bitcoinSerializeToStream(java.io.OutputStream stream)
Serializes this message to the provided stream.
|
boolean |
equals(java.lang.Object o) |
java.net.InetAddress |
getAddr() |
java.lang.String |
getHostname() |
int |
getPort() |
java.math.BigInteger |
getServices() |
java.net.InetSocketAddress |
getSocketAddress() |
long |
getTime() |
int |
hashCode() |
static PeerAddress |
localhost(NetworkParameters params) |
protected void |
parse() |
java.net.InetSocketAddress |
toSocketAddress() |
java.lang.String |
toString() |
adjustLength, adjustLength, setParent, unCache
bitcoinSerialize, bitcoinSerialize, getHash, getMessageSize, getParams, hasMoreBytes, isCached, isRecached, readByteArray, readBytes, readHash, readInt64, readStr, readUint32, readUint64, readVarInt, readVarInt, unsafeBitcoinSerialize
public PeerAddress(NetworkParameters params, byte[] payload, int offset, int protocolVersion) throws ProtocolException
ProtocolException
public PeerAddress(NetworkParameters params, byte[] payload, int offset, int protocolVersion, Message parent, MessageSerializer serializer) throws ProtocolException
params
- NetworkParameters object.payload
- Bitcoin protocol formatted byte array containing message content.offset
- The location of the first payload byte within the array.protocolVersion
- Bitcoin protocol version.serializer
- the serializer to use for this message.ProtocolException
public PeerAddress(NetworkParameters params, java.net.InetAddress addr, int port, int protocolVersion, java.math.BigInteger services)
public PeerAddress(NetworkParameters params, java.net.InetAddress addr, int port)
public PeerAddress(NetworkParameters params, java.net.InetAddress addr)
public PeerAddress(NetworkParameters params, java.net.InetSocketAddress addr)
InetSocketAddress
. An InetSocketAddress can take in as parameters an
InetAddress or a String hostname. If you want to connect to a .onion, set the hostname to the .onion address.public PeerAddress(NetworkParameters params, java.lang.String hostname, int port)
public static PeerAddress localhost(NetworkParameters params)
protected void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Message
bitcoinSerializeToStream
in class Message
java.io.IOException
protected void parse() throws ProtocolException
parse
in class Message
ProtocolException
public java.lang.String getHostname()
public java.net.InetAddress getAddr()
public java.net.InetSocketAddress getSocketAddress()
public int getPort()
public java.math.BigInteger getServices()
public long getTime()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.net.InetSocketAddress toSocketAddress()