private static ImmutableMap<Capability, Integer> calculateCapabilityOffsets(
      final ImmutableRangeMap<Integer, Capability> agreedCaps) {
    final ImmutableMap.Builder<Capability, Integer> capToOffset = ImmutableMap.builder();
    for (final Map.Entry<Range<Integer>, Capability> entry :
        agreedCaps.asMapOfRanges().entrySet()) {
      capToOffset.put(entry.getValue(), entry.getKey().lowerEndpoint());
    }
    return capToOffset.build();
  }
Given a message from a peer, determine which capability the message corresponds to and maps the
message code to the appropriate value.

@param receivedMessage The message received from a peer.
@return The interpreted message.
ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/wire/CapabilityMultiplexer.java