Skip to content

Commit

Permalink
Remove unused params (#6173)
Browse files Browse the repository at this point in the history
## Motivation

Cleaning up the code a little bit



Co-authored-by: ConvallariaMaj <132993066+ConvallariaMaj@users.noreply.github.com>
  • Loading branch information
ConvallariaMaj and ConvallariaMaj committed Jul 23, 2024
1 parent ef254a4 commit d6be04e
Show file tree
Hide file tree
Showing 30 changed files with 152 additions and 174 deletions.
2 changes: 1 addition & 1 deletion activation/nipost.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func withConditionalTimeout(ctx context.Context, timeout time.Duration) (context
return ctx, func() {}
}

// Submit the challenge to a single PoET.
// Submit the challenge (register) to a single PoET.
func (nb *NIPostBuilder) submitPoetChallenge(
ctx context.Context,
nodeID types.NodeID,
Expand Down
1 change: 0 additions & 1 deletion activation/poetdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func (db *PoetDb) Validate(
return fmt.Errorf("failed to validate poet proof for poetID %x round %s: %w", shortID, roundID, err)
}
// TODO(noamnelke): validate signature (or extract public key and use for salting merkle hashes)

return nil
}

Expand Down
16 changes: 8 additions & 8 deletions api/grpcserver/admin_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ func NewAdminService(db *sql.Database, dataDir string, p peers) *AdminService {
}

// RegisterService registers this service with a grpc server instance.
func (a AdminService) RegisterService(server *grpc.Server) {
func (a *AdminService) RegisterService(server *grpc.Server) {
pb.RegisterAdminServiceServer(server, a)
}

func (s AdminService) RegisterHandlerService(mux *runtime.ServeMux) error {
return pb.RegisterAdminServiceHandlerServer(context.Background(), mux, s)
func (a *AdminService) RegisterHandlerService(mux *runtime.ServeMux) error {
return pb.RegisterAdminServiceHandlerServer(context.Background(), mux, a)
}

// String returns the name of this service.
func (a AdminService) String() string {
func (a *AdminService) String() string {
return "AdminService"
}

func (a AdminService) CheckpointStream(
func (a *AdminService) CheckpointStream(
req *pb.CheckpointStreamRequest,
stream pb.AdminService_CheckpointStreamServer,
) error {
Expand Down Expand Up @@ -118,13 +118,13 @@ func (a AdminService) CheckpointStream(
}
}

func (a AdminService) Recover(ctx context.Context, _ *pb.RecoverRequest) (*emptypb.Empty, error) {
func (a *AdminService) Recover(ctx context.Context, _ *pb.RecoverRequest) (*emptypb.Empty, error) {
ctxzap.Info(ctx, "going to recover from checkpoint")
a.recover()
return &emptypb.Empty{}, nil
}

func (a AdminService) EventsStream(req *pb.EventStreamRequest, stream pb.AdminService_EventsStreamServer) error {
func (a *AdminService) EventsStream(_ *pb.EventStreamRequest, stream pb.AdminService_EventsStreamServer) error {
sub, buf, err := events.SubscribeUserEvents(events.WithBuffer(1000))
if err != nil {
return status.Errorf(codes.FailedPrecondition, err.Error())
Expand Down Expand Up @@ -156,7 +156,7 @@ func (a AdminService) EventsStream(req *pb.EventStreamRequest, stream pb.AdminSe
}
}

func (a AdminService) PeerInfoStream(_ *emptypb.Empty, stream pb.AdminService_PeerInfoStreamServer) error {
func (a *AdminService) PeerInfoStream(_ *emptypb.Empty, stream pb.AdminService_PeerInfoStreamServer) error {
for _, p := range a.p.GetPeers() {
select {
case <-stream.Context().Done():
Expand Down
8 changes: 4 additions & 4 deletions api/grpcserver/admin_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestAdminService_Checkpoint(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(ctx, t, cfg)
conn := dialGrpc(t, cfg)
c := pb.NewAdminServiceClient(conn)

stream, err := c.CheckpointStream(ctx, &pb.CheckpointStreamRequest{SnapshotLayer: snapshot})
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestAdminService_CheckpointError(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(ctx, t, cfg)
conn := dialGrpc(t, cfg)
c := pb.NewAdminServiceClient(conn)

stream, err := c.CheckpointStream(ctx, &pb.CheckpointStreamRequest{SnapshotLayer: snapshot})
Expand All @@ -121,7 +121,7 @@ func TestAdminService_Recovery(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(ctx, t, cfg)
conn := dialGrpc(t, cfg)
c := pb.NewAdminServiceClient(conn)

_, err := c.Recover(ctx, &pb.RecoverRequest{})
Expand All @@ -141,7 +141,7 @@ func TestAdminService_PeerInfo(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(ctx, t, cfg)
conn := dialGrpc(t, cfg)
c := pb.NewAdminServiceClient(conn)

p1 := p2p.Peer("p1")
Expand Down
18 changes: 9 additions & 9 deletions api/grpcserver/debug_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ type DebugService struct {
}

// RegisterService registers this service with a grpc server instance.
func (d DebugService) RegisterService(server *grpc.Server) {
func (d *DebugService) RegisterService(server *grpc.Server) {
pb.RegisterDebugServiceServer(server, d)
}

func (s DebugService) RegisterHandlerService(mux *runtime.ServeMux) error {
return pb.RegisterDebugServiceHandlerServer(context.Background(), mux, s)
func (d *DebugService) RegisterHandlerService(mux *runtime.ServeMux) error {
return pb.RegisterDebugServiceHandlerServer(context.Background(), mux, d)
}

// String returns the name of this service.
func (d DebugService) String() string {
func (d *DebugService) String() string {
return "DebugService"
}

Expand All @@ -59,7 +59,7 @@ func NewDebugService(db *sql.Database, conState conservativeState, host networkI
}

// Accounts returns current counter and balance for all accounts.
func (d DebugService) Accounts(ctx context.Context, in *pb.AccountsRequest) (*pb.AccountsResponse, error) {
func (d *DebugService) Accounts(ctx context.Context, in *pb.AccountsRequest) (*pb.AccountsResponse, error) {
var (
accts []*types.Account
err error
Expand Down Expand Up @@ -96,7 +96,7 @@ func (d DebugService) Accounts(ctx context.Context, in *pb.AccountsRequest) (*pb
}

// NetworkInfo query provides NetworkInfoResponse.
func (d DebugService) NetworkInfo(ctx context.Context, _ *emptypb.Empty) (*pb.NetworkInfoResponse, error) {
func (d *DebugService) NetworkInfo(ctx context.Context, _ *emptypb.Empty) (*pb.NetworkInfoResponse, error) {
resp := &pb.NetworkInfoResponse{Id: d.netInfo.ID().String()}
for _, a := range d.netInfo.ListenAddresses() {
resp.ListenAddresses = append(resp.ListenAddresses, a.String())
Expand Down Expand Up @@ -139,7 +139,7 @@ func (d DebugService) NetworkInfo(ctx context.Context, _ *emptypb.Empty) (*pb.Ne
}

// ActiveSet query provides hare active set for the specified epoch.
func (d DebugService) ActiveSet(ctx context.Context, req *pb.ActiveSetRequest) (*pb.ActiveSetResponse, error) {
func (d *DebugService) ActiveSet(ctx context.Context, req *pb.ActiveSetRequest) (*pb.ActiveSetResponse, error) {
actives, err := d.oracle.ActiveSet(ctx, types.EpochID(req.Epoch))
if err != nil {
return nil, status.Errorf(codes.Internal, fmt.Sprintf("active set for epoch %d: %s", req.Epoch, err.Error()))
Expand All @@ -152,7 +152,7 @@ func (d DebugService) ActiveSet(ctx context.Context, req *pb.ActiveSetRequest) (
}

// ProposalsStream streams all proposals confirmed by hare.
func (d DebugService) ProposalsStream(_ *emptypb.Empty, stream pb.DebugService_ProposalsStreamServer) error {
func (d *DebugService) ProposalsStream(_ *emptypb.Empty, stream pb.DebugService_ProposalsStreamServer) error {
sub := events.SubscribeProposals()
if sub == nil {
return status.Errorf(codes.FailedPrecondition, "event reporting is not enabled")
Expand All @@ -177,7 +177,7 @@ func (d DebugService) ProposalsStream(_ *emptypb.Empty, stream pb.DebugService_P
}
}

func (d DebugService) ChangeLogLevel(ctx context.Context, req *pb.ChangeLogLevelRequest) (*emptypb.Empty, error) {
func (d *DebugService) ChangeLogLevel(ctx context.Context, req *pb.ChangeLogLevelRequest) (*emptypb.Empty, error) {
level, err := zap.ParseAtomicLevel(req.GetLevel())
if err != nil {
return nil, fmt.Errorf("parse level: %w", err)
Expand Down
24 changes: 12 additions & 12 deletions api/grpcserver/globalstate_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ type GlobalStateService struct {
}

// RegisterService registers this service with a grpc server instance.
func (s GlobalStateService) RegisterService(server *grpc.Server) {
func (s *GlobalStateService) RegisterService(server *grpc.Server) {
pb.RegisterGlobalStateServiceServer(server, s)
}

func (s GlobalStateService) RegisterHandlerService(mux *runtime.ServeMux) error {
func (s *GlobalStateService) RegisterHandlerService(mux *runtime.ServeMux) error {
return pb.RegisterGlobalStateServiceHandlerServer(context.Background(), mux, s)
}

// String returns the name of the service.
func (s GlobalStateService) String() string {
func (s *GlobalStateService) String() string {
return "GlobalStateService"
}

Expand All @@ -46,7 +46,7 @@ func NewGlobalStateService(msh meshAPI, conState conservativeState) *GlobalState
}

// GlobalStateHash returns the latest layer and its computed global state hash.
func (s GlobalStateService) GlobalStateHash(
func (s *GlobalStateService) GlobalStateHash(
context.Context,
*pb.GlobalStateHashRequest,
) (*pb.GlobalStateHashResponse, error) {
Expand All @@ -60,7 +60,7 @@ func (s GlobalStateService) GlobalStateHash(
}}, nil
}

func (s GlobalStateService) getAccount(addr types.Address) (acct *pb.Account, err error) {
func (s *GlobalStateService) getAccount(addr types.Address) (acct *pb.Account, err error) {
balanceActual, err := s.conState.GetBalance(addr)
if err != nil {
return nil, err
Expand All @@ -84,7 +84,7 @@ func (s GlobalStateService) getAccount(addr types.Address) (acct *pb.Account, er
}

// Account returns current and projected counter and balance for one account.
func (s GlobalStateService) Account(ctx context.Context, in *pb.AccountRequest) (*pb.AccountResponse, error) {
func (s *GlobalStateService) Account(ctx context.Context, in *pb.AccountRequest) (*pb.AccountResponse, error) {
if in.AccountId == nil {
return nil, status.Errorf(codes.InvalidArgument, "`AccountId` must be provided")
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func (s GlobalStateService) Account(ctx context.Context, in *pb.AccountRequest)
}

// AccountDataQuery returns historical account data such as rewards and receipts.
func (s GlobalStateService) AccountDataQuery(
func (s *GlobalStateService) AccountDataQuery(
ctx context.Context,
in *pb.AccountDataQueryRequest,
) (*pb.AccountDataQueryResponse, error) {
Expand Down Expand Up @@ -200,7 +200,7 @@ func (s GlobalStateService) AccountDataQuery(
}

// SmesherDataQuery returns historical info on smesher rewards.
func (s GlobalStateService) SmesherDataQuery(
func (s *GlobalStateService) SmesherDataQuery(
_ context.Context,
in *pb.SmesherDataQueryRequest,
) (*pb.SmesherDataQueryResponse, error) {
Expand All @@ -210,7 +210,7 @@ func (s GlobalStateService) SmesherDataQuery(
// STREAMS

// AccountDataStream exposes a stream of account-related data.
func (s GlobalStateService) AccountDataStream(
func (s *GlobalStateService) AccountDataStream(
in *pb.AccountDataStreamRequest,
stream pb.GlobalStateService_AccountDataStreamServer,
) error {
Expand Down Expand Up @@ -328,15 +328,15 @@ func (s GlobalStateService) AccountDataStream(
}

// SmesherRewardStream exposes a stream of smesher rewards.
func (s GlobalStateService) SmesherRewardStream(
func (s *GlobalStateService) SmesherRewardStream(
in *pb.SmesherRewardStreamRequest,
stream pb.GlobalStateService_SmesherRewardStreamServer,
) error {
return status.Errorf(codes.Unimplemented, "DEPRECATED")
}

// AppEventStream exposes a stream of emitted app events.
func (s GlobalStateService) AppEventStream(
func (s *GlobalStateService) AppEventStream(
*pb.AppEventStreamRequest,
pb.GlobalStateService_AppEventStreamServer,
) error {
Expand All @@ -347,7 +347,7 @@ func (s GlobalStateService) AppEventStream(
}

// GlobalStateStream exposes a stream of global data data items: rewards, receipts, account info, global state hash.
func (s GlobalStateService) GlobalStateStream(
func (s *GlobalStateService) GlobalStateStream(
in *pb.GlobalStateStreamRequest,
stream pb.GlobalStateService_GlobalStateStreamServer,
) error {
Expand Down
5 changes: 1 addition & 4 deletions api/grpcserver/globalstate_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"math"
"testing"
"time"

pb "github.com/spacemeshos/api/release/go/spacemesh/v1"
"github.com/stretchr/testify/require"
Expand All @@ -30,9 +29,7 @@ func setupGlobalStateService(t *testing.T) (*globalStateServiceConn, context.Con
cfg, cleanup := launchServer(t, svc)
t.Cleanup(cleanup)

grpcCtx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
conn := dialGrpc(grpcCtx, t, cfg)
conn := dialGrpc(t, cfg)
client := pb.NewGlobalStateServiceClient(conn)

return &globalStateServiceConn{
Expand Down
Loading

0 comments on commit d6be04e

Please sign in to comment.