|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.bitcoin.core.Message
com.google.bitcoin.core.ChildMessage
com.google.bitcoin.core.PeerAddress
public class PeerAddress
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.google.bitcoin.core.Message |
|---|
Message.LazyParseException |
| Field Summary |
|---|
| Fields inherited from class com.google.bitcoin.core.Message |
|---|
bytes, checksum, cursor, length, MAX_SIZE, offset, params, parsed, parseLazy, parseRetain, protocolVersion, recached, UNKNOWN_LENGTH |
| Constructor Summary | |
|---|---|
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)
|
|
PeerAddress(NetworkParameters params,
byte[] payload,
int offset,
int protocolVersion)
Construct a peer address from a serialized payload. |
|
PeerAddress(NetworkParameters params,
byte[] msg,
int offset,
int protocolVersion,
Message parent,
boolean parseLazy,
boolean parseRetain)
Construct a peer address from a serialized payload. |
|
| Method Summary | |
|---|---|
protected void |
bitcoinSerializeToStream(OutputStream stream)
Serializes this message to the provided stream. |
boolean |
equals(Object o)
|
InetAddress |
getAddr()
|
int |
getMessageSize()
This should be overridden to extract correct message size in the case of lazy parsing. |
int |
getPort()
|
BigInteger |
getServices()
|
long |
getTime()
|
int |
hashCode()
|
static PeerAddress |
localhost(NetworkParameters params)
|
protected void |
parse()
|
protected void |
parseLite()
Perform the most minimal parse possible to calculate the length of the message. |
void |
setAddr(InetAddress addr)
|
void |
setPort(int port)
|
void |
setServices(BigInteger services)
|
void |
setTime(long time)
|
InetSocketAddress |
toSocketAddress()
|
String |
toString()
|
| Methods inherited from class com.google.bitcoin.core.ChildMessage |
|---|
adjustLength, adjustLength, setParent, unCache |
| Methods inherited from class com.google.bitcoin.core.Message |
|---|
bitcoinSerialize, bitcoinSerialize, ensureParsed, getHash, getParams, isCached, isParsed, isRecached, maybeParse, unsafeBitcoinSerialize |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PeerAddress(NetworkParameters params,
byte[] payload,
int offset,
int protocolVersion)
throws ProtocolException
ProtocolException
public PeerAddress(NetworkParameters params,
byte[] msg,
int offset,
int protocolVersion,
Message parent,
boolean parseLazy,
boolean parseRetain)
throws ProtocolException
params - NetworkParameters object.msg - Bitcoin protocol formatted byte array containing message content.offset - The location of the first msg byte within the array.protocolVersion - Bitcoin protocol version.parseLazy - Whether to perform a full parse immediately or delay until a read is requested.parseRetain - Whether to retain the backing byte array for quick reserialization.
If true and the backing byte array is invalidated due to modification of a field then
the cached bytes may be repopulated and retained if the message is serialized again in the future.
ProtocolException
public PeerAddress(InetAddress addr,
int port,
int protocolVersion)
public PeerAddress(InetAddress addr,
int port)
public PeerAddress(InetAddress addr)
public PeerAddress(InetSocketAddress addr)
| Method Detail |
|---|
public static PeerAddress localhost(NetworkParameters params)
protected void bitcoinSerializeToStream(OutputStream stream)
throws IOException
Message
IOExceptionprotected void parseLite()
Message
parseLite in class Message
protected void parse()
throws ProtocolException
ProtocolExceptionpublic int getMessageSize()
Message
getMessageSize in class Messagepublic InetAddress getAddr()
public void setAddr(InetAddress addr)
addr - the addr to setpublic int getPort()
public void setPort(int port)
port - the port to setpublic BigInteger getServices()
public void setServices(BigInteger services)
services - the services to setpublic long getTime()
public void setTime(long time)
time - the time to setpublic String toString()
toString in class Objectpublic boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic InetSocketAddress toSocketAddress()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||