Skip to content

Commit

Permalink
refactor: use google.protobuf.Timestamp instead of int64
Browse files Browse the repository at this point in the history
Replaced the int64 timestamp with google.protobuf.Timestamp in the GetIdsResponse message. Adjusted the generated code to handle the new timestamp type and updated the protobuf imports accordingly.
  • Loading branch information
tzdybal committed Sep 18, 2024
1 parent a3c5a89 commit bd91110
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 60 deletions.
4 changes: 3 additions & 1 deletion proto/da/da.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax = "proto3";
package da;

import "google/protobuf/timestamp.proto";

// DAService is the protobuf service definition for interaction with Data Availability layers.
service DAService {
// MaxBlobSize returns the maximum blob size
Expand Down Expand Up @@ -79,7 +81,7 @@ message GetIdsRequest {
// GetIdsResponse is the response type for the GetIds rpc method.
message GetIdsResponse {
repeated ID ids = 1;
int64 timestamp = 2;
google.protobuf.Timestamp timestamp = 2;
}

// GetProofsRequest is the request type for the GetProofs rpc method.
Expand Down
8 changes: 6 additions & 2 deletions proxy/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package grpc

import (
"context"
"time"

"github.com/cosmos/gogoproto/types"
"google.golang.org/grpc"

"github.com/rollkit/go-da"
Expand Down Expand Up @@ -73,7 +73,11 @@ func (c *Client) GetIDs(ctx context.Context, height uint64, namespace da.Namespa
return nil, err
}

return &da.GetIDsResult{IDs: idsPB2DA(resp.Ids), Timestamp: time.UnixMicro(resp.Timestamp)}, nil
timestamp, err := types.TimestampFromProto(resp.Timestamp)
if err != nil {
return nil, err
}
return &da.GetIDsResult{IDs: idsPB2DA(resp.Ids), Timestamp: timestamp}, nil
}

// GetProofs returns inclusion Proofs for all Blobs located in DA at given height.
Expand Down
7 changes: 6 additions & 1 deletion proxy/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grpc
import (
"context"

"github.com/cosmos/gogoproto/types"
"google.golang.org/grpc"

"github.com/rollkit/go-da"
Expand Down Expand Up @@ -43,7 +44,11 @@ func (p *proxySrv) GetIds(ctx context.Context, request *pbda.GetIdsRequest) (*pb
return nil, err
}

return &pbda.GetIdsResponse{Ids: idsDA2PB(ret.IDs), Timestamp: ret.Timestamp.UnixMicro()}, nil
timestamp, err := types.TimestampProto(ret.Timestamp)
if err != nil {
return nil, err
}
return &pbda.GetIdsResponse{Ids: idsDA2PB(ret.IDs), Timestamp: timestamp}, nil
}

func (p *proxySrv) Commit(ctx context.Context, request *pbda.CommitRequest) (*pbda.CommitResponse, error) {
Expand Down
141 changes: 85 additions & 56 deletions types/pb/da/da.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bd91110

Please sign in to comment.