public Task RequestBlocksAsync(string peerId, Root peerHeadRoot, Slot finalizedSlot, Slot peerHeadSlot)
        {
            // NOTE: Currently just requests entire range, one at a time, to get small testnet working.
            // Will need more sophistication in future, e.g. request interleaved blocks and stuff.

            // Start with the block for the next slot after our finalized state
            Slot  startSlot = finalizedSlot + Slot.One;
            ulong count     = peerHeadSlot - finalizedSlot;
            ulong step      = 1;
            BeaconBlocksByRange beaconBlocksByRange = new BeaconBlocksByRange(peerHeadRoot, startSlot, count, step);

            byte[]      peerUtf8 = Encoding.UTF8.GetBytes(peerId);
            Span <byte> encoded  = new byte[Ssz.Ssz.BeaconBlocksByRangeLength];

            Ssz.Ssz.Encode(encoded, beaconBlocksByRange);

            if (_logger.IsDebug())
            {
                LogDebug.RpcSend(_logger, RpcDirection.Request, nameof(MethodUtf8.BeaconBlocksByRange), peerId,
                                 encoded.Length, null);
            }

            if (!_mothraLibp2p.SendRpcRequest(MethodUtf8.BeaconBlocksByRange, peerUtf8, encoded))
            {
                if (_logger.IsWarn())
                {
                    Log.RpcRequestNotSentAsPeeeringNotStarted(_logger, nameof(MethodUtf8.BeaconBlocksByRange), null);
                }
            }

            return(Task.CompletedTask);
        }
 public static void SendRpcRequest(this IMothraLibp2p mothraLibp2p, string method, string peer,
                                   ReadOnlySpan <byte> data)
 {
     byte[] methodUtf8 = Encoding.UTF8.GetBytes(method);
     byte[] peerUtf8   = Encoding.UTF8.GetBytes(peer);
     mothraLibp2p.SendRpcRequest(methodUtf8, peerUtf8, data);
 }