Skip to content

Commit

Permalink
Handle case where parent is in previous epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Aug 19, 2023
1 parent eadbac4 commit 7b2dacd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion multiepoch-getBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ func (multi *MultiEpoch) handleGetBlock(ctx context.Context, conn *requestContex
{
// get parent slot
parentSlot := uint64(block.Meta.Parent_slot)
if parentSlot != 0 {
if parentSlot != 0 && CalcEpochForSlot(parentSlot) == epochNumber {
// NOTE: if the parent is in the same epoch, we can get it from the same epoch handler as the block;
// otherwise, we need to get it from the previous epoch (TODO: implement this)
parentBlock, err := epochHandler.GetBlock(WithSubrapghPrefetch(ctx, false), parentSlot)
if err != nil {
return &jsonrpc2.Error{
Expand All @@ -384,6 +386,8 @@ func (multi *MultiEpoch) handleGetBlock(ctx context.Context, conn *requestContex
parentEntryHash := solana.HashFromBytes(parentEntryNode.Hash)
blockResp.PreviousBlockhash = parentEntryHash.String()
}
} else {
klog.Infof("parent slot is in a different epoch, not implemented yet")
}
}
tim.time("get parent block")
Expand Down

0 comments on commit 7b2dacd

Please sign in to comment.