Skip to content

Commit

Permalink
refactor: update protos to be correctly namespaced
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Jan 16, 2025
1 parent 8d75c25 commit a92023d
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 46 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DataDog/datadog-go/v5 v5.5.0
github.com/Layr-Labs/eigenlayer-contracts v0.4.1-holesky-pepe.0.20240813143901-00fc4b95e9c1
github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.13
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250114181701-acb87ef4eeb5
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250115220323-135176acb92b
github.com/ethereum/go-ethereum v1.14.9
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/google/uuid v1.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ github.com/Layr-Labs/protocol-apis v1.1.1-0.20250114180833-6f2487a7e08c h1:kcTwH
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250114180833-6f2487a7e08c/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250114181701-acb87ef4eeb5 h1:0PLxb8fpwdpWpfk24yhdZzETFCxVMN2yJjRDyBBf6wM=
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250114181701-acb87ef4eeb5/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250115220323-135176acb92b h1:eJmPAq3s+AwOrQUjSFXILCzUstDZobwYEraOZ2NFC1M=
github.com/Layr-Labs/protocol-apis v1.1.1-0.20250115220323-135176acb92b/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpcServer/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rpcServer
import (
"context"

sidecarV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1"
sidecarV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/sidecar"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down
12 changes: 6 additions & 6 deletions pkg/rpcServer/healthHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package rpcServer

import (
"context"
sidecarV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1"
healthV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/health"
)

func (rpc *RpcServer) HealthCheck(ctx context.Context, req *sidecarV1.HealthCheckRequest) (*sidecarV1.HealthCheckResponse, error) {
return &sidecarV1.HealthCheckResponse{
Status: sidecarV1.HealthCheckResponse_SERVING,
func (rpc *RpcServer) HealthCheck(ctx context.Context, req *healthV1.HealthCheckRequest) (*healthV1.HealthCheckResponse, error) {
return &healthV1.HealthCheckResponse{
Status: healthV1.HealthCheckResponse_SERVING,
}, nil
}

func (rpc *RpcServer) ReadyCheck(ctx context.Context, req *sidecarV1.ReadyRequest) (*sidecarV1.ReadyResponse, error) {
return &sidecarV1.ReadyResponse{
func (rpc *RpcServer) ReadyCheck(ctx context.Context, req *healthV1.ReadyRequest) (*healthV1.ReadyResponse, error) {
return &healthV1.ReadyResponse{
Ready: true,
}, nil
}
16 changes: 8 additions & 8 deletions pkg/rpcServer/proofsHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ package rpcServer
import (
"context"
"github.com/Layr-Labs/eigenlayer-rewards-proofs/pkg/claimgen"
sidecarV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1"
rewardsV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/rewards"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

func convertClaimProofToRPCResponse(solidityProof *claimgen.IRewardsCoordinatorRewardsMerkleClaimStrings) *sidecarV1.Proof {
tokenLeaves := make([]*sidecarV1.TokenLeaf, 0)
func convertClaimProofToRPCResponse(solidityProof *claimgen.IRewardsCoordinatorRewardsMerkleClaimStrings) *rewardsV1.Proof {
tokenLeaves := make([]*rewardsV1.TokenLeaf, 0)

for _, l := range solidityProof.TokenLeaves {
tokenLeaves = append(tokenLeaves, &sidecarV1.TokenLeaf{
tokenLeaves = append(tokenLeaves, &rewardsV1.TokenLeaf{
Token: l.Token.String(),
CumulativeEarnings: l.CumulativeEarnings,
})
}

return &sidecarV1.Proof{
return &rewardsV1.Proof{
Root: solidityProof.Root,
RootIndex: solidityProof.RootIndex,
EarnerIndex: solidityProof.EarnerIndex,
EarnerTreeProof: solidityProof.EarnerTreeProof,
EarnerLeaf: &sidecarV1.EarnerLeaf{
EarnerLeaf: &rewardsV1.EarnerLeaf{
Earner: solidityProof.EarnerLeaf.Earner.String(),
EarnerTokenRoot: solidityProof.EarnerLeaf.EarnerTokenRoot,
},
Expand All @@ -33,7 +33,7 @@ func convertClaimProofToRPCResponse(solidityProof *claimgen.IRewardsCoordinatorR
}
}

func (rpc *RpcServer) GenerateClaimProof(ctx context.Context, req *sidecarV1.GenerateClaimProofRequest) (*sidecarV1.GenerateClaimProofResponse, error) {
func (rpc *RpcServer) GenerateClaimProof(ctx context.Context, req *rewardsV1.GenerateClaimProofRequest) (*rewardsV1.GenerateClaimProofResponse, error) {
earner := req.GetEarnerAddress()
tokens := req.GetTokens()
rootIndex := req.GetRootIndex()
Expand All @@ -52,7 +52,7 @@ func (rpc *RpcServer) GenerateClaimProof(ctx context.Context, req *sidecarV1.Gen

solidityClaim := claimgen.FormatProofForSolidity(root, claim)

return &sidecarV1.GenerateClaimProofResponse{
return &rewardsV1.GenerateClaimProofResponse{
Proof: convertClaimProofToRPCResponse(solidityClaim),
}, nil
}
31 changes: 31 additions & 0 deletions pkg/rpcServer/protocolHandlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package rpcServer

import (
"context"
protocolV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/protocol"
)

func (rpc *RpcServer) GetRegisteredAvsForOperator(ctx context.Context, request *protocolV1.GetRegisteredAvsForOperatorRequest) (*protocolV1.GetRegisteredAvsForOperatorResponse, error) {
//TODO implement me
panic("implement me")
}

func (rpc *RpcServer) GetDelegatedStrategiesForOperator(ctx context.Context, request *protocolV1.GetDelegatedStrategiesForOperatorRequest) (*protocolV1.GetDelegatedStrategiesForOperatorResponse, error) {
//TODO implement me
panic("implement me")
}

func (rpc *RpcServer) GetOperatorDelegatedStakeForStrategy(ctx context.Context, request *protocolV1.GetOperatorDelegatedStakeForStrategyRequest) (*protocolV1.GetOperatorDelegatedStakeForStrategyResponse, error) {
//TODO implement me
panic("implement me")
}

func (rpc *RpcServer) GetDelegatedStakersForOperator(ctx context.Context, request *protocolV1.GetDelegatedStakersForOperatorRequest) (*protocolV1.GetDelegatedStakersForOperatorResponse, error) {
//TODO implement me
panic("implement me")
}

func (rpc *RpcServer) GetStakerShares(ctx context.Context, request *protocolV1.GetStakerSharesRequest) (*protocolV1.GetStakerSharesResponse, error) {
//TODO implement me
panic("implement me")
}
44 changes: 22 additions & 22 deletions pkg/rpcServer/rewardsHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rpcServer
import (
"context"
"errors"
sidecarV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1"
rewardsV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/rewards"
"github.com/Layr-Labs/sidecar/pkg/rewards"
"github.com/Layr-Labs/sidecar/pkg/rewardsCalculatorQueue"
"github.com/Layr-Labs/sidecar/pkg/utils"
Expand All @@ -13,11 +13,11 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)

func (rpc *RpcServer) GetRewardsRoot(ctx context.Context, req *sidecarV1.GetRewardsRootRequest) (*sidecarV1.GetRewardsRootResponse, error) {
func (rpc *RpcServer) GetRewardsRoot(ctx context.Context, req *rewardsV1.GetRewardsRootRequest) (*rewardsV1.GetRewardsRootResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetRewardsRoot not implemented")
}

func (rpc *RpcServer) GenerateRewards(ctx context.Context, req *sidecarV1.GenerateRewardsRequest) (*sidecarV1.GenerateRewardsResponse, error) {
func (rpc *RpcServer) GenerateRewards(ctx context.Context, req *rewardsV1.GenerateRewardsRequest) (*rewardsV1.GenerateRewardsResponse, error) {
cutoffDate := req.GetCutoffDate()
waitForComplete := req.GetWaitForComplete()

Expand Down Expand Up @@ -46,13 +46,13 @@ func (rpc *RpcServer) GenerateRewards(ctx context.Context, req *sidecarV1.Genera
}
return nil, status.Error(codes.Internal, err.Error())
}
return &sidecarV1.GenerateRewardsResponse{
return &rewardsV1.GenerateRewardsResponse{
CutoffDate: cutoffDate,
Queued: queued,
}, nil
}

func (rpc *RpcServer) GenerateRewardsRoot(ctx context.Context, req *sidecarV1.GenerateRewardsRootRequest) (*sidecarV1.GenerateRewardsRootResponse, error) {
func (rpc *RpcServer) GenerateRewardsRoot(ctx context.Context, req *rewardsV1.GenerateRewardsRootRequest) (*rewardsV1.GenerateRewardsRootResponse, error) {
cutoffDate := req.GetCutoffDate()
if cutoffDate == "" {
return nil, status.Error(codes.InvalidArgument, "snapshot date is required")
Expand Down Expand Up @@ -101,13 +101,13 @@ func (rpc *RpcServer) GenerateRewardsRoot(ctx context.Context, req *sidecarV1.Ge
zap.String("cutoffDate", cutoffDate),
)

return &sidecarV1.GenerateRewardsRootResponse{
return &rewardsV1.GenerateRewardsRootResponse{
RewardsRoot: rootString,
RewardsCalcEndDate: rewardsCalcEndDate,
}, nil
}

func (rpc *RpcServer) GenerateStakerOperators(ctx context.Context, req *sidecarV1.GenerateStakerOperatorsRequest) (*sidecarV1.GenerateStakerOperatorsResponse, error) {
func (rpc *RpcServer) GenerateStakerOperators(ctx context.Context, req *rewardsV1.GenerateStakerOperatorsRequest) (*rewardsV1.GenerateStakerOperatorsResponse, error) {
cutoffDate := req.GetCutoffDate()

if cutoffDate == "" {
Expand Down Expand Up @@ -136,12 +136,12 @@ func (rpc *RpcServer) GenerateStakerOperators(ctx context.Context, req *sidecarV
}
return nil, status.Error(codes.Internal, err.Error())
}
return &sidecarV1.GenerateStakerOperatorsResponse{
return &rewardsV1.GenerateStakerOperatorsResponse{
Queued: queued,
}, nil
}

func (rpc *RpcServer) BackfillStakerOperators(ctx context.Context, req *sidecarV1.BackfillStakerOperatorsRequest) (*sidecarV1.BackfillStakerOperatorsResponse, error) {
func (rpc *RpcServer) BackfillStakerOperators(ctx context.Context, req *rewardsV1.BackfillStakerOperatorsRequest) (*rewardsV1.BackfillStakerOperatorsResponse, error) {

var err error
queued := false
Expand All @@ -164,52 +164,52 @@ func (rpc *RpcServer) BackfillStakerOperators(ctx context.Context, req *sidecarV
}
return nil, status.Error(codes.Internal, err.Error())
}
return &sidecarV1.BackfillStakerOperatorsResponse{
return &rewardsV1.BackfillStakerOperatorsResponse{
Queued: queued,
}, nil
}

func (rpc *RpcServer) GetRewardsForSnapshot(ctx context.Context, req *sidecarV1.GetRewardsForSnapshotRequest) (*sidecarV1.GetRewardsForSnapshotResponse, error) {
func (rpc *RpcServer) GetRewardsForSnapshot(ctx context.Context, req *rewardsV1.GetRewardsForSnapshotRequest) (*rewardsV1.GetRewardsForSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetRewardsForSnapshot not implemented")
}

func (rpc *RpcServer) GetAttributableRewardsForSnapshot(ctx context.Context, req *sidecarV1.GetAttributableRewardsForSnapshotRequest) (*sidecarV1.GetAttributableRewardsForSnapshotResponse, error) {
func (rpc *RpcServer) GetAttributableRewardsForSnapshot(ctx context.Context, req *rewardsV1.GetAttributableRewardsForSnapshotRequest) (*rewardsV1.GetAttributableRewardsForSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetAttributableRewardsForSnapshot not implemented")
}

func (rpc *RpcServer) GetAttributableRewardsForDistributionRoot(ctx context.Context, req *sidecarV1.GetAttributableRewardsForDistributionRootRequest) (*sidecarV1.GetAttributableRewardsForDistributionRootResponse, error) {
func (rpc *RpcServer) GetAttributableRewardsForDistributionRoot(ctx context.Context, req *rewardsV1.GetAttributableRewardsForDistributionRootRequest) (*rewardsV1.GetAttributableRewardsForDistributionRootResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetAttributableRewardsForDistributionRoot not implemented")
}

func (rpc *RpcServer) GetAvailableRewards(ctx context.Context, req *sidecarV1.GetAvailableRewardsRequest) (*sidecarV1.GetAvailableRewardsResponse, error) {
func (rpc *RpcServer) GetAvailableRewards(ctx context.Context, req *rewardsV1.GetAvailableRewardsRequest) (*rewardsV1.GetAvailableRewardsResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetAvailableRewards not implemented")
}

func (rpc *RpcServer) GetTotalClaimedRewards(ctx context.Context, req *sidecarV1.GetTotalClaimedRewardsRequest) (*sidecarV1.GetTotalClaimedRewardsResponse, error) {
func (rpc *RpcServer) GetTotalClaimedRewards(ctx context.Context, req *rewardsV1.GetTotalClaimedRewardsRequest) (*rewardsV1.GetTotalClaimedRewardsResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetTotalClaimedRewards not implemented")
}

func (rpc *RpcServer) GetAvailableRewardsTokens(ctx context.Context, req *sidecarV1.GetAvailableRewardsTokensRequest) (*sidecarV1.GetAvailableRewardsTokensResponse, error) {
func (rpc *RpcServer) GetAvailableRewardsTokens(ctx context.Context, req *rewardsV1.GetAvailableRewardsTokensRequest) (*rewardsV1.GetAvailableRewardsTokensResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetAvailableRewardsTokens not implemented")
}

func (rpc *RpcServer) GetSummarizedRewardsForEarner(ctx context.Context, req *sidecarV1.GetSummarizedRewardsForEarnerRequest) (*sidecarV1.GetSummarizedRewardsForEarnerResponse, error) {
func (rpc *RpcServer) GetSummarizedRewardsForEarner(ctx context.Context, req *rewardsV1.GetSummarizedRewardsForEarnerRequest) (*rewardsV1.GetSummarizedRewardsForEarnerResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetSummarizedRewardsForEarner not implemented")
}

func (rpc *RpcServer) GetClaimedRewardsByBlock(ctx context.Context, req *sidecarV1.GetClaimedRewardsByBlockRequest) (*sidecarV1.GetClaimedRewardsByBlockResponse, error) {
func (rpc *RpcServer) GetClaimedRewardsByBlock(ctx context.Context, req *rewardsV1.GetClaimedRewardsByBlockRequest) (*rewardsV1.GetClaimedRewardsByBlockResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetClaimedRewardsByBlock not implemented")
}

func (rpc *RpcServer) ListDistributionRoots(ctx context.Context, req *sidecarV1.ListDistributionRootsRequest) (*sidecarV1.ListDistributionRootsResponse, error) {
func (rpc *RpcServer) ListDistributionRoots(ctx context.Context, req *rewardsV1.ListDistributionRootsRequest) (*rewardsV1.ListDistributionRootsResponse, error) {
roots, err := rpc.rewardsCalculator.ListDistributionRoots()
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

responseRoots := make([]*sidecarV1.DistributionRoot, 0, len(roots))
responseRoots := make([]*rewardsV1.DistributionRoot, 0, len(roots))
for _, root := range roots {
responseRoots = append(responseRoots, &sidecarV1.DistributionRoot{
responseRoots = append(responseRoots, &rewardsV1.DistributionRoot{
Root: root.Root,
RootIndex: root.RootIndex,
RewardsCalculationEnd: timestamppb.New(root.RewardsCalculationEnd),
Expand All @@ -224,7 +224,7 @@ func (rpc *RpcServer) ListDistributionRoots(ctx context.Context, req *sidecarV1.
})
}

return &sidecarV1.ListDistributionRootsResponse{
return &rewardsV1.ListDistributionRootsResponse{
DistributionRoots: responseRoots,
}, nil
}
24 changes: 16 additions & 8 deletions pkg/rpcServer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import (
"context"
"errors"
"fmt"
v1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1"
eventsV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/events"
healthV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/health"
protocolV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/protocol"
rewardsV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/rewards"
sidecarV1 "github.com/Layr-Labs/protocol-apis/gen/protos/eigenlayer/sidecar/v1/sidecar"
"github.com/Layr-Labs/sidecar/internal/logger"
"github.com/Layr-Labs/sidecar/pkg/eigenState/stateManager"
"github.com/Layr-Labs/sidecar/pkg/eventBus/eventBusTypes"
Expand All @@ -31,7 +34,6 @@ type RpcServerConfig struct {
}

type RpcServer struct {
v1.UnimplementedRpcServer
Logger *zap.Logger
rpcConfig *RpcServerConfig
blockStore storage.BlockStore
Expand Down Expand Up @@ -67,20 +69,26 @@ func NewRpcServer(
}

func (s *RpcServer) registerHandlers(ctx context.Context, grpcServer *grpc.Server, mux *runtime.ServeMux) error {
v1.RegisterHealthServer(grpcServer, s)
if err := v1.RegisterHealthHandlerServer(ctx, mux, s); err != nil {
healthV1.RegisterHealthServer(grpcServer, s)
if err := healthV1.RegisterHealthHandlerServer(ctx, mux, s); err != nil {
s.Logger.Sugar().Errorw("Failed to register Health server", zap.Error(err))
return err
}

v1.RegisterRpcServer(grpcServer, s)
if err := v1.RegisterRpcHandlerServer(ctx, mux, s); err != nil {
sidecarV1.RegisterRpcServer(grpcServer, s)
if err := sidecarV1.RegisterRpcHandlerServer(ctx, mux, s); err != nil {
s.Logger.Sugar().Errorw("Failed to register SidecarRpc server", zap.Error(err))
return err
}

v1.RegisterRewardsServer(grpcServer, s)
if err := v1.RegisterRewardsHandlerServer(ctx, mux, s); err != nil {
rewardsV1.RegisterRewardsServer(grpcServer, s)
if err := rewardsV1.RegisterRewardsHandlerServer(ctx, mux, s); err != nil {
s.Logger.Sugar().Errorw("Failed to register Rewards server", zap.Error(err))
return err
}

protocolV1.RegisterProtocolServer(grpcServer, s)
if err := protocolV1.RegisterProtocolHandlerServer(ctx, mux, s); err != nil {
s.Logger.Sugar().Errorw("Failed to register Rewards server", zap.Error(err))
return err
}
Expand Down
63 changes: 63 additions & 0 deletions pkg/service/protocolDataService/protocol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package protocolDataService

import (
"github.com/Layr-Labs/sidecar/internal/config"
"github.com/Layr-Labs/sidecar/pkg/eigenState/stakerShares"
"github.com/Layr-Labs/sidecar/pkg/service/types"
"go.uber.org/zap"
"gorm.io/gorm"
)

type ProtocolDataService struct {
db *gorm.DB
logger *zap.Logger
globalConfig *config.Config
}

func NewProtocolDataService(
db *gorm.DB,
logger *zap.Logger,
globalConfig *config.Config,
) *ProtocolDataService {
return &ProtocolDataService{
db: db,
logger: logger,
globalConfig: globalConfig,
}
}

func (pds *ProtocolDataService) ListRegisteredAVSsForOperator(operator string, blockHeight uint64) (interface{}, error) {
return nil, nil
}

func (pds *ProtocolDataService) ListDelegatedStrategiesForOperator(operator string, blockHeight uint64) (interface{}, error) {
return nil, nil
}

func (pds *ProtocolDataService) GetOperatorDelegatedStake(operator string, strategy string, blockHeight uint64) (interface{}, error) {
return nil, nil
}

func (pds *ProtocolDataService) ListDelegatedStakersForOperator(operator string, blockHeight uint64, pagination types.Pagination) (interface{}, error) {
return nil, nil
}

func (pds *ProtocolDataService) ListStakerShares(staker string, blockHeight uint64) ([]*stakerShares.StakerShareDeltas, error) {
shares := make([]*stakerShares.StakerShareDeltas, 0)

whereParams := []interface{}{staker}
where := "staker = ?"
if blockHeight > 0 {
where += " AND block_height <= ?"
whereParams = append(whereParams, blockHeight)
}

res := pds.db.Model(&stakerShares.StakerShareDeltas{}).
Where(where, whereParams...).
Find(&shares)

if res.Error != nil {
return nil, res.Error
}
return shares, nil
}
Loading

0 comments on commit a92023d

Please sign in to comment.