Skip to content

Commit

Permalink
More question
Browse files Browse the repository at this point in the history
  • Loading branch information
dadepo committed Sep 16, 2024
1 parent 0215ff4 commit 936d798
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ledger/insert_shred.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const sig = @import("../sig.zig");
const sig = @import("sig.zig");

const ledger = sig.ledger;
const meta = ledger.meta;
Expand Down Expand Up @@ -874,7 +874,7 @@ pub const ShredInserter = struct {
) bool {
const shred_index: u64 = @intCast(shred.fields.common.index);
// QUESTION: is the "shred_index < slot_meta.consecutive_received_from_0" check needed?
// Ie would there ever be a case where data_index.contains(shred_index) is true but
// Ie would there ever be a case where data_index.contains(shred_index) is true but
// shred_index < slot_meta.consecutive_received_from_0 is false? If not then is data_index.contains(shred_index)
// not enough check?
// Also if shred_index > slot_meta.consecutive_received_from_0 is true and also data_index.contains(shred_index) is true
Expand All @@ -898,6 +898,9 @@ pub const ShredInserter = struct {
const shred_index_u32 = shred.fields.common.index;
const shred_index_u64: u64 = @intCast(shred_index_u32);
const is_last_in_slot = shred.isLastInSlot();
// QUESTION/SUGGESTION rename this to is_valid (or similar) instead of sanitize as santize gives the
// impression this is fixing up things and updating the shred, when it is only running a bunch of
// validation.
assertOk(shred.sanitize());

// Check that we do not receive a shred with either:
Expand Down
2 changes: 2 additions & 0 deletions src/ledger/reader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ pub const BlockstoreReader = struct {
}

/// Analogous to [get_data_shred](https://github.com/anza-xyz/agave/blob/15dbe7fb0fc07e11aaad89de1576016412c7eb9e/ledger/src/blockstore.rs#L2220)
// QUESTION: Agave does a check if the shred retrieved is of the right variant. Ie if it is not
// LegacyCode or MerkleCode. Is the implementation of the retrieval already preventing that here?
pub fn getDataShred(self: *Self, slot: Slot, index: u64) !?BytesRef {
const shred = try self.db.getBytes(schema.data_shred, .{ slot, index }) orelse return null;
if (shred.data.len != DataShred.constants.payload_size) {
Expand Down

0 comments on commit 936d798

Please sign in to comment.