Skip to content

Commit f4a94c3

Browse files
committed
rpc: implement timestamp filter in AddrReceives
1 parent b32efef commit f4a94c3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

rpcserver.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,16 @@ func (r *rpcServer) AddrReceives(ctx context.Context,
22712271
sqlQuery.StatusTo = &status
22722272
}
22732273

2274+
// Add timestamp filtering if specified
2275+
if req.StartTimestamp > 0 {
2276+
startTime := time.Unix(int64(req.StartTimestamp), 0)
2277+
sqlQuery.CreationTimeFrom = &startTime
2278+
}
2279+
if req.EndTimestamp > 0 {
2280+
endTime := time.Unix(int64(req.EndTimestamp), 0)
2281+
sqlQuery.CreationTimeTo = &endTime
2282+
}
2283+
22742284
events, err := r.cfg.AddrBook.QueryEvents(ctx, sqlQuery)
22752285
if err != nil {
22762286
return nil, fmt.Errorf("error querying events: %w", err)
@@ -4154,12 +4164,6 @@ func (r *rpcServer) FetchSupplyCommit(ctx context.Context,
41544164
req *unirpc.FetchSupplyCommitRequest) (
41554165
*unirpc.FetchSupplyCommitResponse, error) {
41564166

4157-
// Check the rate limiter to see if we need to wait at all. If not then
4158-
// this'll be a noop.
4159-
if err := r.proofQueryRateLimiter.Wait(ctx); err != nil {
4160-
return nil, err
4161-
}
4162-
41634167
groupPubKey, err := unmarshalGroupKey(
41644168
req.GetGroupKeyBytes(), req.GetGroupKeyStr(),
41654169
)
@@ -4731,12 +4735,6 @@ func (r *rpcServer) InsertSupplyCommit(ctx context.Context,
47314735
req *unirpc.InsertSupplyCommitRequest) (
47324736
*unirpc.InsertSupplyCommitResponse, error) {
47334737

4734-
// Check the rate limiter to see if we need to wait at all. If not then
4735-
// this'll be a noop.
4736-
if err := r.proofQueryRateLimiter.Wait(ctx); err != nil {
4737-
return nil, err
4738-
}
4739-
47404738
groupPubKey, err := unmarshalGroupKey(
47414739
req.GetGroupKeyBytes(), req.GetGroupKeyStr(),
47424740
)

0 commit comments

Comments
 (0)