예제 #1
0
        internal static int ParseLogEntryPrologue(ReadOnlySpan <byte> input, out LogEntryMetadata metadata)
        {
            var reader = new SpanReader <byte>(input);

            metadata = new LogEntryMetadata(ref reader);
            return(LogEntryMetadata.Size);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }