internal static int ParseLogEntryPrologue(ReadOnlySpan <byte> input, out LogEntryMetadata metadata) { var reader = new SpanReader <byte>(input); metadata = new LogEntryMetadata(ref reader); return(LogEntryMetadata.Size); }
internal static int ParseAnnouncement(ReadOnlySpan <byte> input, out ushort remotePort, out long term, out long snapshotIndex, out LogEntryMetadata metadata) { var reader = new SpanReader <byte>(input); remotePort = reader.ReadUInt16(true); term = reader.ReadInt64(true); snapshotIndex = reader.ReadInt64(true); metadata = new LogEntryMetadata(ref reader); return(reader.ConsumedCount); }
private int WriteAnnouncement(Span <byte> output) { var writer = new SpanWriter <byte>(output); writer.WriteUInt16(myPort, true); writer.WriteInt64(term, true); writer.WriteInt64(snapshotIndex, true); LogEntryMetadata.Create(snapshot).Serialize(ref writer); return(writer.WrittenCount); }