Skip to content

Commit

Permalink
api: return raw public key in resp (#4658)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak committed Jul 6, 2023
1 parent bcaabf8 commit 5649a9c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
4 changes: 1 addition & 3 deletions api/grpcserver/grpcserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,8 @@ func TestSmesherService(t *testing.T) {
logtest.SetupGlobal(t)
res, err := c.SmesherID(context.Background(), &empty.Empty{})
require.NoError(t, err)
nodeAddr := types.GenerateAddress(signer.NodeID().Bytes())
resAddr, err := types.StringToAddress(res.AccountId.Address)
require.NoError(t, err)
require.Equal(t, nodeAddr.String(), resAddr.String())
require.Equal(t, signer.NodeID().Bytes(), res.PublicKey)
})

t.Run("SetCoinbaseMissingArgs", func(t *testing.T) {
Expand Down
11 changes: 2 additions & 9 deletions api/grpcserver/smesher_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,12 @@ func (s SmesherService) StopSmeshing(ctx context.Context, in *pb.StopSmeshingReq

// SmesherID returns the smesher ID of this node.
func (s SmesherService) SmesherID(context.Context, *empty.Empty) (*pb.SmesherIDResponse, error) {
log.Info("GRPC SmesherService.SmesherID")

nodeID := s.smeshingProvider.SmesherID()
addr := types.GenerateAddress(nodeID[:])
return &pb.SmesherIDResponse{AccountId: &pb.AccountId{Address: addr.String()}}, nil
return &pb.SmesherIDResponse{PublicKey: s.smeshingProvider.SmesherID().Bytes()}, nil
}

// Coinbase returns the current coinbase setting of this node.
func (s SmesherService) Coinbase(context.Context, *empty.Empty) (*pb.CoinbaseResponse, error) {
log.Info("GRPC SmesherService.Coinbase")

addr := s.smeshingProvider.Coinbase()
return &pb.CoinbaseResponse{AccountId: &pb.AccountId{Address: addr.String()}}, nil
return &pb.CoinbaseResponse{AccountId: &pb.AccountId{Address: s.smeshingProvider.Coinbase().String()}}, nil
}

// SetCoinbase sets the current coinbase setting of this node.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/pyroscope-io/pyroscope v0.37.2
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0
github.com/seehuhn/mt19937 v1.0.0
github.com/spacemeshos/api/release/go v1.14.0
github.com/spacemeshos/api/release/go v1.14.1-0.20230706180837-eca1fc098955
github.com/spacemeshos/economics v0.1.0
github.com/spacemeshos/fixed v0.1.0
github.com/spacemeshos/go-scale v1.1.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spacemeshos/api/release/go v1.14.0 h1:1DJZzr/9tr3z4y//yqj6DvSd8df0g4ISVYQLQWA08C0=
github.com/spacemeshos/api/release/go v1.14.0/go.mod h1:6dbFQWsygFOlpPdmNNwiBbqEXAvK+s11UJO70VI1Yaw=
github.com/spacemeshos/api/release/go v1.14.1-0.20230706180837-eca1fc098955 h1:XMUc/iUsH3G42VPOKypuKIL/6riwWYJyfkoQX4AY6YY=
github.com/spacemeshos/api/release/go v1.14.1-0.20230706180837-eca1fc098955/go.mod h1:6dbFQWsygFOlpPdmNNwiBbqEXAvK+s11UJO70VI1Yaw=
github.com/spacemeshos/economics v0.1.0 h1:PJAKbhBKqbbdCYTB29pkmc8sYqK3pKUAiuAvQxuSJEg=
github.com/spacemeshos/economics v0.1.0/go.mod h1:Bz0wRDwCOUP1A6w3cPW6iuUBGME8Tz48sIriYiohsBg=
github.com/spacemeshos/fixed v0.1.0 h1:20KIGvxLlAsuidQrvuwwHe6PrvqeTKzbJIsScbmnUPQ=
Expand Down

0 comments on commit 5649a9c

Please sign in to comment.