@Override protected void parse() throws ProtocolException { // Format of a serialized address: // uint32 timestamp // uint64 services (flags determining what the node can do) // 16 bytes ip address // 2 bytes port num if (protocolVersion > 31402) time = readUint32(); else time = -1; services = readUint64(); byte[] addrBytes = readBytes(16); try { addr = InetAddress.getByAddress(addrBytes); } catch (UnknownHostException e) { throw new RuntimeException(e); // Cannot happen. } port = ((0xFF & payload[cursor++]) << 8) | (0xFF & payload[cursor++]); // The 4 byte difference is the uint32 timestamp that was introduced in version 31402 length = protocolVersion > 31402 ? MESSAGE_SIZE : MESSAGE_SIZE - 4; }
@Override protected void parse() throws ProtocolException { // Format of a serialized address: // uint32 timestamp // uint64 services (flags determining what the node can do) // 16 bytes ip address // 2 bytes port num if (protocolVersion > 31402) time = readUint32(); else time = -1; services = readUint64(); byte[] addrBytes = readBytes(16); try { addr = InetAddress.getByAddress(addrBytes); } catch (UnknownHostException e) { throw new RuntimeException(e); // Cannot happen. } port = ((0xFF & payload[cursor++]) << 8) | (0xFF & payload[cursor++]); // The 4 byte difference is the uint32 timestamp that was introduced in version 31402 length = protocolVersion > 31402 ? MESSAGE_SIZE : MESSAGE_SIZE - 4; }
@Override protected void parse() throws ProtocolException { // Format of a serialized address: // uint32 timestamp // uint64 services (flags determining what the node can do) // 16 bytes ip address // 2 bytes port num if (protocolVersion > 31402) time = readUint32(); else time = -1; services = readUint64(); byte[] addrBytes = readBytes(16); try { addr = InetAddress.getByAddress(addrBytes); } catch (UnknownHostException e) { throw new RuntimeException(e); // Cannot happen. } port = ((0xFF & payload[cursor++]) << 8) | (0xFF & payload[cursor++]); // The 4 byte difference is the uint32 timestamp that was introduced in version 31402 length = protocolVersion > 31402 ? MESSAGE_SIZE : MESSAGE_SIZE - 4; }
@Override protected void parse() throws ProtocolException { // Format of a serialized address: // uint32 timestamp // uint64 services (flags determining what the node can do) // 16 bytes ip address // 2 bytes port num if (protocolVersion > 31402) time = readUint32(); else time = -1; services = readUint64(); byte[] addrBytes = readBytes(16); try { addr = InetAddress.getByAddress(addrBytes); } catch (UnknownHostException e) { throw new RuntimeException(e); // Cannot happen. } port = ((0xFF & payload[cursor++]) << 8) | (0xFF & payload[cursor++]); // The 4 byte difference is the uint32 timestamp that was introduced in version 31402 length = protocolVersion > 31402 ? MESSAGE_SIZE : MESSAGE_SIZE - 4; }