Skip to content

Commit

Permalink
scan select range into new submission object each time
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-iohk committed Mar 20, 2024
1 parent 8af034e commit 4b1a789
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,16 @@ func (kc *CassandraContext) selectRange(startTime, endTime time.Time) ([]Submiss
iter := kc.Session.Query(query, startTime, endTime).Iter()

var submissions []Submission
var submission Submission
for iter.Scan(&submission.SubmittedAtDate, &submission.Shard, &submission.SubmittedAt, &submission.Submitter,
&submission.CreatedAt, &submission.BlockHash, &submission.RawBlock, &submission.RemoteAddr, &submission.PeerID,
&submission.SnarkWork, &submission.GraphqlControlPort, &submission.BuiltWithCommitSha, &submission.StateHash,
&submission.Parent, &submission.Height, &submission.Slot, &submission.ValidationError, &submission.Verified) {
for {
// we need to scan into new submission object each time
// otherwise we will end up with a slice of pointers to the same object
var submission Submission
if !iter.Scan(&submission.SubmittedAtDate, &submission.Shard, &submission.SubmittedAt, &submission.Submitter,
&submission.CreatedAt, &submission.BlockHash, &submission.RawBlock, &submission.RemoteAddr, &submission.PeerID,
&submission.SnarkWork, &submission.GraphqlControlPort, &submission.BuiltWithCommitSha, &submission.StateHash,
&submission.Parent, &submission.Height, &submission.Slot, &submission.ValidationError, &submission.Verified) {
break
}
submissions = append(submissions, submission)
}
if err := iter.Close(); err != nil {
Expand Down

0 comments on commit 4b1a789

Please sign in to comment.