sizeHint method

  1. @override
int sizeHint(
  1. PeerInfo<H, N> value
)
override

If possible give a hint of expected size of the encoding.

This method is used inside default implementation of encode to avoid re-allocations.

Implementation

@override
int sizeHint(PeerInfo<H, N> value) {
  int size = 0;
  size += StrCodec.codec.sizeHint(value.peerId);
  size += StrCodec.codec.sizeHint(value.roles);
  size += hashCodec.sizeHint(value.bestHash);
  size += numberCodec.sizeHint(value.bestNumber);
  return size;
}