public void StoredLogEntryIsFunAndImplicitlyConverts() { var s = new StoredLogEntry() { Body = new byte[] { 1, 2, 3, 4 }, Index = 42L, Term = 122L }; byte[] buffer = s; StoredLogEntry s2 = buffer; Assert.Equal(s.Index, s2.Index); Assert.Equal(s.Body, s2.Body); }
/// <inheritdocs/> public LogEntry[] GetEntries(long index, int count) { if (index < LogOffset) { throw new EntriesNotAvailableAnymoreException(index, LogOffset); } if (index + count - 1 > LastIndex) { throw new InvalidOperationException($"We do not have these entries yet. index: {index}, count: {count} and LastIndex: {LastIndex}"); } var list = new LogEntry[count]; using (var tx = _env.BeginReadOnlyTransaction()) { for (long i = index; i < index + count; i++) { Bufferable b = i; if (!tx.TryGetDuplicate(_logDb, LogKey, ref b)) { throw new InvalidOperationException($"Could not find index {i} in the logs."); } StoredLogEntry s = b.Buffer; if (s.Index != i) { throw new InvalidDataException($"Corruption in the highest. Supposedly loaded {index} but came out {s.Index}"); } list[i - index] = new LogEntry() { Body = s.Body, Term = s.Term }; } } return(list); }