NetworkAddress.deserialize constructor

NetworkAddress.deserialize(
  1. Uint8List data,
  2. int offset, {
  3. bool includeTimestamp = false,
})

Deserialize address from bytes

Implementation

factory NetworkAddress.deserialize(Uint8List data, int offset, {bool includeTimestamp = false}) {
  int pos = offset;

  int timestamp = 0;
  if (includeTimestamp) {
    timestamp = _decodeUint32(data, pos);
    pos += 4;
  }

  final services = _decodeUint64(data, pos);
  pos += 8;

  final ip = data.sublist(pos, pos + 16).toList();
  pos += 16;

  final port = (data[pos] << 8) | data[pos + 1];

  return NetworkAddress(
    timestamp: timestamp,
    services: services,
    ip: ip,
    port: port,
  );
}