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

gsfa reader for slot range #184

Merged
merged 3 commits into from
Nov 15, 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
33 changes: 33 additions & 0 deletions multiepoch-getSignaturesForAddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ func (ser *MultiEpoch) getGsfaReadersInEpochDescendingOrder() ([]*gsfa.GsfaReade
return gsfaReaders, epochNums
}

// getGsfaReadersInEpochDescendingOrder returns a list of gsfa readers in epoch order (from most recent to oldest).
func (ser *MultiEpoch) getGsfaReadersInEpochDescendingOrderForSlotRange(ctx context.Context, startSlot, endSlot uint64) ([]*gsfa.GsfaReader, []uint64) {
ser.mu.RLock()
defer ser.mu.RUnlock()

startEpoch := CalcEpochForSlot(startSlot)
endEpoch := CalcEpochForSlot(endSlot)

epochs := make([]*Epoch, 0, endEpoch-startEpoch+1)
for _, epoch := range ser.epochs {

if epoch.Epoch() >= startEpoch && epoch.Epoch() <= endEpoch {
epochs = append(epochs, epoch)
}
}

// sort epochs by epoch number (from biggest to smallest):
sort.Slice(epochs, func(i, j int) bool {
return epochs[i].epoch > epochs[j].epoch
})

gsfaReaders := make([]*gsfa.GsfaReader, 0, len(epochs))
epochNums := make([]uint64, 0, len(epochs))
for _, epoch := range epochs {
if epoch.gsfaReader != nil {
epoch.gsfaReader.SetEpoch(epoch.Epoch())
gsfaReaders = append(gsfaReaders, epoch.gsfaReader)
epochNums = append(epochNums, epoch.Epoch())
}
}
return gsfaReaders, epochNums
}

func countTransactions(v gsfa.EpochToTransactionObjects) int {
var count int
for _, txs := range v {
Expand Down
Loading