Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use blocktime index for send transactions #206

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions grpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,21 @@ func (multi *MultiEpoch) processSlotTransactions(
txResp.Transaction.Meta = tx.Meta
txResp.Transaction.Index = tx.Index

// To do: add blocketime after index work is done
epochNumber := slottools.CalcEpochForSlot(slot)
epochHandler, err := multi.GetEpoch(epochNumber)
if err != nil {
return status.Errorf(codes.NotFound, "Epoch %d is not available", epochNumber)
}
blocktimeIndex := epochHandler.GetBlocktimeIndex()
if blocktimeIndex != nil {
blocktime, err := blocktimeIndex.Get(uint64(slot))
if err != nil {
return status.Errorf(codes.Internal, "Failed to get blocktime: %v", err)
}
txResp.BlockTime = int64(blocktime)
} else {
return status.Errorf(codes.Internal, "Failed to get blocktime: blocktime index is nil")
}
}

if err := ser.Send(txResp); err != nil {
Expand Down Expand Up @@ -878,7 +892,16 @@ func (multi *MultiEpoch) processSlotTransactions(
}
txResp.Slot = uint64(txn.Slot)

// To do: add blocktime after index work is done
blocktimeIndex := epochHandler.GetBlocktimeIndex()
if blocktimeIndex != nil {
blocktime, err := blocktimeIndex.Get(uint64(txn.Slot))
if err != nil {
return status.Errorf(codes.Internal, "Failed to get blocktime: %v", err)
}
txResp.BlockTime = int64(blocktime)
} else {
return status.Errorf(codes.Internal, "Failed to get blocktime: blocktime index is nil")
}
}

if err := ser.Send(txResp); err != nil {
Expand Down
Loading