public class VersionMessage extends Message
After creating yourself a VersionMessage, you can pass it to PeerGroup.setVersionMessage(VersionMessage)
to ensure it will be used for each new connection.
Message.LazyParseException
Modifier and Type | Field and Description |
---|---|
long |
bestHeight
How many blocks are in the chain, according to the other side.
|
static String |
BITCOINJ_VERSION
The version of this library release, as a string.
|
int |
clientVersion
The version number of the protocol spoken.
|
static String |
LIBRARY_SUBVER
The value that is prepended to the subVer field of this application.
|
long |
localServices
Flags defining what is supported.
|
PeerAddress |
myAddr
What the other side believes the address of this program is.
|
static int |
NODE_NETWORK
A services flag that denotes whether the peer has a copy of the block chain or not.
|
boolean |
relayTxesBeforeFilter
Whether or not to relay tx invs before a filter is received
|
String |
subVer
An additional string that today the official client sets to the empty string.
|
PeerAddress |
theirAddr
What the other side believes their own address is.
|
long |
time
What the other side believes the current time to be, in seconds.
|
bytes, checksum, cursor, length, MAX_SIZE, offset, params, parsed, parseLazy, parseRetain, protocolVersion, recached, UNKNOWN_LENGTH
Constructor and Description |
---|
VersionMessage(NetworkParameters params,
byte[] msg) |
VersionMessage(NetworkParameters params,
int newBestHeight)
Equivalent to VersionMessage(params, newBestHeight, true)
|
VersionMessage(NetworkParameters params,
int newBestHeight,
boolean relayTxesBeforeFilter) |
Modifier and Type | Method and Description |
---|---|
void |
appendToSubVer(String name,
String version,
String comments)
Appends the given user-agent information to the subVer field.
|
void |
bitcoinSerializeToStream(OutputStream buf)
Serializes this message to the provided stream.
|
VersionMessage |
duplicate() |
boolean |
equals(Object o) |
boolean |
hasBlockChain()
Returns true if the version message indicates the sender has a full copy of the block chain,
or if it's running in client mode (only has the headers).
|
int |
hashCode() |
boolean |
isBloomFilteringSupported()
Returns true if the clientVersion field is >= FilteredBlock.MIN_PROTOCOL_VERSION.
|
boolean |
isPingPongSupported()
Returns true if the clientVersion field is >= Pong.MIN_PROTOCOL_VERSION.
|
void |
parse() |
protected void |
parseLite()
Perform the most minimal parse possible to calculate the length of the message.
|
String |
toString() |
adjustLength, bitcoinSerialize, bitcoinSerialize, ensureParsed, getHash, getMessageSize, getParams, isCached, isParsed, isRecached, maybeParse, unCache, unsafeBitcoinSerialize
public static final int NODE_NETWORK
public int clientVersion
public long localServices
NODE_NETWORK
is the only flag defined.public long time
public PeerAddress myAddr
public PeerAddress theirAddr
public String subVer
public long bestHeight
public boolean relayTxesBeforeFilter
public static final String BITCOINJ_VERSION
public static final String LIBRARY_SUBVER
public VersionMessage(NetworkParameters params, byte[] msg) throws ProtocolException
ProtocolException
public VersionMessage(NetworkParameters params, int newBestHeight)
public VersionMessage(NetworkParameters params, int newBestHeight, boolean relayTxesBeforeFilter)
protected void parseLite() throws ProtocolException
Message
parseLite
in class Message
ProtocolException
public void parse() throws ProtocolException
ProtocolException
public void bitcoinSerializeToStream(OutputStream buf) throws IOException
Message
IOException
public boolean hasBlockChain()
public VersionMessage duplicate()
public void appendToSubVer(String name, String version, @Nullable String comments)
There can be as many components as you feel a need for, and the version string can be anything, but it is recommended to use A.B.C where A = major, B = minor and C = revision for software releases, and dates for auto-generated source repository snapshots. A valid subVer begins and ends with a slash, therefore name and version are not allowed to contain such characters.
Anything put in the "comments" field will appear in brackets and may be used for platform info, or anything else. For example, calling appendToSubVer("MultiBit", "1.0", "Windows") will result in a subVer being set of "/BitCoinJ:1.0/MultiBit:1.0(Windows)/. Therefore the / ( and ) characters are reserved in all these components. If you don't want to add a comment (recommended), pass null.
See BIP 14 for more information.
comments
- Optional (can be null) platform or other node specific information.IllegalArgumentException
- if name, version or comments contains invalid characters.public boolean isPingPongSupported()
public boolean isBloomFilteringSupported()
Copyright © 2014. All rights reserved.