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(InetAddress addr)
Constructs a peer address from the given IP address.
|
PeerAddress(InetAddress addr,
int port)
Constructs a peer address from the given IP address and port.
|
PeerAddress(InetAddress addr,
int port,
int protocolVersion)
Construct a peer address from a memorized or hardcoded address.
|
PeerAddress(InetSocketAddress addr)
Constructs a peer address from an
InetSocketAddress . |
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,
InetAddress addr)
Constructs a peer address from the given IP address.
|
PeerAddress(NetworkParameters params,
InetAddress addr,
int port)
Constructs a peer address from the given IP address and port.
|
PeerAddress(NetworkParameters params,
InetSocketAddress addr)
Constructs a peer address from an
InetSocketAddress . |
PeerAddress(NetworkParameters params,
String hostname,
int port)
Constructs a peer address from a stringified hostname+port.
|
PeerAddress(String hostname,
int port)
Constructs a peer address from a stringified hostname+port.
|
Modifier and Type | Method and Description |
---|---|
protected void |
bitcoinSerializeToStream(OutputStream stream)
Serializes this message to the provided stream.
|
boolean |
equals(Object o) |
InetAddress |
getAddr() |
String |
getHostname() |
int |
getPort() |
BigInteger |
getServices() |
InetSocketAddress |
getSocketAddress() |
long |
getTime() |
int |
hashCode() |
static PeerAddress |
localhost(NetworkParameters params) |
protected void |
parse() |
void |
setAddr(InetAddress addr) |
void |
setPort(int port) |
void |
setServices(BigInteger services) |
void |
setTime(long time) |
InetSocketAddress |
toSocketAddress() |
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(InetAddress addr, int port, int protocolVersion)
public PeerAddress(InetAddress addr, int port)
public PeerAddress(NetworkParameters params, InetAddress addr, int port)
public PeerAddress(InetAddress addr)
public PeerAddress(NetworkParameters params, InetAddress addr)
public PeerAddress(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.
Protocol version is the default. Protocol version is the default
for Bitcoin.public PeerAddress(NetworkParameters params, 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(String hostname, int port)
public PeerAddress(NetworkParameters params, String hostname, int port)
public static PeerAddress localhost(NetworkParameters params)
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException
Message
bitcoinSerializeToStream
in class Message
IOException
protected void parse() throws ProtocolException
parse
in class Message
ProtocolException
public String getHostname()
public InetAddress getAddr()
public InetSocketAddress getSocketAddress()
public void setAddr(InetAddress addr)
public int getPort()
public void setPort(int port)
public BigInteger getServices()
public void setServices(BigInteger services)
public long getTime()
public void setTime(long time)
public InetSocketAddress toSocketAddress()
Copyright © 2016. All rights reserved.