Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
  • Loading branch information
anjor committed Nov 14, 2024
1 parent 9e5f476 commit 8640e47
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions grpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,5 +696,60 @@ func blockContainsAccounts(block *old_faithful_grpc.BlockResponse, accounts []st
}

return false
}

func (multi *MultiEpoch) StreamTransactions(params *old_faithful_grpc.StreamTransactionsRequest, ser old_faithful_grpc.OldFaithful_StreamTransactionsServer) error {
ctx := ser.Context()

startSlot := params.StartSlot
endSlot := startSlot + maxSlotsToStream

if params.EndSlot != nil {
endSlot = *params.EndSlot
}

filterFunc := func(tx *old_faithful_grpc.Transaction) bool {
if params.Filter == nil || len(params.Filter.AccountInclude) == 0 {
return true
}

return txContainsAccounts(tx, params.Filter.AccountInclude)
}

for slot := startSlot; slot <= endSlot; slot++ {
select {
case <-ctx.Done():
return ctx.Err()
default:
}

block, err := multi.GetBlock(ctx, &old_faithful_grpc.BlockRequest{Slot: slot})
if err != nil {
if status.Code(err) == codes.NotFound {
continue // is this the right thing to do?
}
return err
}

for _, tx := range block.Transactions {
if filterFunc(tx) {
if err := ser.Send(constructTransactionResponse(tx)); err != nil {
return err
}
}
}
}

return nil
}

func txContainsAccounts(tx *old_faithful_grpc.Transaction, accounts []string) bool {
return true
}

func constructTransactionResponse(tx *old_faithful_grpc.Transaction) *old_faithful_grpc.TransactionResponse {
// to do
return &old_faithful_grpc.TransactionResponse{
Transaction: tx,
}
}

0 comments on commit 8640e47

Please sign in to comment.