Skip to content

Commit

Permalink
sharding per 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-iohk committed Mar 11, 2024
1 parent ca1b908 commit 77c0f3d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/delegation_backend/aws_keyspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ func (kc *KeyspaceContext) insertSubmission(submission *Submission) error {
}

// calculateShard returns the shard number for a given submission time.
// 0-599 are the possible shard numbers, each representing a 6-second interval.
// 0-599 are the possible shard numbers, each representing a 144-second interval within 24h.
// shard = (3600 * hour + 60 * minute + second) // 144
func calculateShard(submittedAt time.Time) int {
hour := submittedAt.Hour()
minute := submittedAt.Minute()
second := submittedAt.Second()
return minute*10 + second/6
return (3600*hour + 60*minute + second) / 144
}

func (kc *KeyspaceContext) tryInsertSubmission(submission *Submission, includeRawBlock bool) error {
Expand Down

0 comments on commit 77c0f3d

Please sign in to comment.