Package org.bitcoinj.core
Class Services
java.lang.Object
org.bitcoinj.core.Services
Wrapper for services bitfield used in various messages of the Bitcoin protocol. Each bit represents a node service,
e.g.
NODE_NETWORK
if the node serves the full blockchain.
Instances of this class are immutable and should be treated as Java value-based.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Number of bytes of this bitfield.static final int
A service bit used by Bitcoin-ABC to announce Bitcoin Cash nodes.static final int
A service bit that denotes whether the peer supports BIP37 bloom filters or not.static final int
Indicates the node will service basic block filter requests (BIP157, BIP158).static final int
A service bit that denotes whether the peer has a full copy of the block chain or not.static final int
A service bit that denotes whether the peer has at least the last two days worth of blockchain (BIP159).static final int
Indicates the node supports BIP324 transport.static final int
Indicates that a node can be asked for blocks and transactions including witness data. -
Method Summary
Modifier and TypeMethodDescriptionboolean
anyOf
(long bitmask) Checks if at least one of the given node services is signaled by this bitfield.long
bits()
Gets the 64 bits of this bitfield, each representing a node service.boolean
boolean
has
(long bitmask) Checks if given specific node services are signaled by this bitfield.boolean
hasAny()
Checks if this bitfield signals any node services at all.int
hashCode()
static Services
none()
Constructs a services bitfield representing "no node services".static Services
of
(long bits) Wrap 64 bits, each representing a node service.static Services
read
(ByteBuffer buf) Construct a services bitfield by reading from the given buffer.byte[]
Allocates a byte array and writes the node service bits into it.toString()
write
(ByteBuffer buf) Write the node service bits into the given buffer.
-
Field Details
-
NODE_NETWORK
public static final int NODE_NETWORKA service bit that denotes whether the peer has a full copy of the block chain or not.- See Also:
-
NODE_BLOOM
public static final int NODE_BLOOMA service bit that denotes whether the peer supports BIP37 bloom filters or not. The service bit is defined in BIP111.- See Also:
-
NODE_WITNESS
public static final int NODE_WITNESSIndicates that a node can be asked for blocks and transactions including witness data.- See Also:
-
NODE_COMPACT_FILTERS
public static final int NODE_COMPACT_FILTERSIndicates the node will service basic block filter requests (BIP157, BIP158).- See Also:
-
NODE_NETWORK_LIMITED
public static final int NODE_NETWORK_LIMITEDA service bit that denotes whether the peer has at least the last two days worth of blockchain (BIP159).- See Also:
-
NODE_P2P_V2
public static final int NODE_P2P_V2Indicates the node supports BIP324 transport.- See Also:
-
NODE_BITCOIN_CASH
public static final int NODE_BITCOIN_CASHA service bit used by Bitcoin-ABC to announce Bitcoin Cash nodes.- See Also:
-
BYTES
public static final int BYTESNumber of bytes of this bitfield.- See Also:
-
-
Method Details
-
of
Wrap 64 bits, each representing a node service.- Parameters:
bits
- bits to wrap- Returns:
- wrapped service bits
-
none
Constructs a services bitfield representing "no node services".- Returns:
- wrapped service bits
-
read
Construct a services bitfield by reading from the given buffer.- Parameters:
buf
- buffer to read from- Returns:
- wrapped service bits
- Throws:
BufferUnderflowException
- if the read services bitfield extends beyond the remaining bytes of the buffer
-
bits
public long bits()Gets the 64 bits of this bitfield, each representing a node service.- Returns:
- the service bits
-
hasAny
public boolean hasAny()Checks if this bitfield signals any node services at all.- Returns:
- true if at least one service is signaled, false otherwise
-
has
public boolean has(long bitmask) Checks if given specific node services are signaled by this bitfield.- Parameters:
bitmask
- bitmask representing the services to be checked for- Returns:
- true if the given services are all signaled, false otherwise
-
anyOf
public boolean anyOf(long bitmask) Checks if at least one of the given node services is signaled by this bitfield.- Parameters:
bitmask
- bitmask representing the services to be checked for- Returns:
- true if at least one of the given services is signaled, false otherwise
-
write
Write the node service bits into the given buffer.- Parameters:
buf
- buffer to write into- Returns:
- the buffer
- Throws:
BufferOverflowException
- if the service bits don't fit the remaining buffer
-
serialize
public byte[] serialize()Allocates a byte array and writes the node service bits into it.- Returns:
- byte array containing the service bits
-
toString
-
equals
-
hashCode
public int hashCode()
-