Skip to content

Commit

Permalink
Merge pull request #1381 from mesg-foundation/feature/remove-service-del
Browse files Browse the repository at this point in the history
Remove service deletion
  • Loading branch information
Nicolas Mahé authored Sep 30, 2019
2 parents 25d65ef + 7bbdc8c commit 034602b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 250 deletions.
176 changes: 34 additions & 142 deletions protobuf/api/service.pb.go

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

17 changes: 0 additions & 17 deletions protobuf/api/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ service Service {
// It will return an unique identifier which is used to interact with the Service.
rpc Create (CreateServiceRequest) returns (CreateServiceResponse) {}

// Delete a Service.
// An error is returned if one or more Instances of the Service are running.
rpc Delete (DeleteServiceRequest) returns (DeleteServiceResponse) {}

// Get returns a Service matching the criteria of the request.
rpc Get(GetServiceRequest) returns (types.Service) {}

Expand Down Expand Up @@ -69,19 +65,6 @@ message CreateServiceResponse {
];
}

// The request's data for the `Delete` API.
message DeleteServiceRequest {
// The service's hash to delete.
bytes hash = 1 [
(gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash",
(gogoproto.nullable) = false
];
}

// The response's data for the `Delete` API, doesn't contain anything.
message DeleteServiceResponse {
}

// The request's data for the `Get` API.
message GetServiceRequest {
// The service's hash to fetch.
Expand Down
12 changes: 0 additions & 12 deletions sdk/service/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func NewBackend(appFactory *cosmos.AppFactory, ownerships *ownershipsdk.Backend)
appFactory.RegisterStoreKey(backend.storeKey)

backend.cdc.RegisterConcrete(msgCreateService{}, "service/create", nil)
backend.cdc.RegisterConcrete(msgDeleteService{}, "service/delete", nil)

return backend
}
Expand All @@ -58,12 +57,6 @@ func (s *Backend) handler(request cosmostypes.Request, msg cosmostypes.Msg) cosm
return cosmostypes.Result{
Data: srv.Hash,
}
case msgDeleteService:
err := s.Delete(request, msg.Hash)
if err != nil {
return cosmostypes.ErrInternal(err.Error()).Result()
}
return cosmostypes.Result{}
default:
errmsg := fmt.Sprintf("Unrecognized service Msg type: %v", msg.Type())
return cosmostypes.ErrUnknownRequest(errmsg).Result()
Expand All @@ -90,11 +83,6 @@ func (s *Backend) Create(request cosmostypes.Request, msg *msgCreateService) (*s
return create(s.db(request), msg.Request, msg.Owner, s.ownerships, request)
}

// Delete deletes the service by hash.
func (s *Backend) Delete(request cosmostypes.Request, hash hash.Hash) error {
return s.db(request).Delete(hash)
}

// Get returns the service that matches given hash.
func (s *Backend) Get(request cosmostypes.Request, hash hash.Hash) (*service.Service, error) {
return s.db(request).Get(hash)
Expand Down
47 changes: 0 additions & 47 deletions sdk/service/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package servicesdk
import (
"github.com/cosmos/cosmos-sdk/codec"
cosmostypes "github.com/cosmos/cosmos-sdk/types"
"github.com/mesg-foundation/engine/hash"
"github.com/mesg-foundation/engine/protobuf/api"
)

Expand Down Expand Up @@ -50,49 +49,3 @@ func (msg msgCreateService) GetSignBytes() []byte {
func (msg msgCreateService) GetSigners() []cosmostypes.AccAddress {
return []cosmostypes.AccAddress{msg.Owner}
}

// --------------------------------------------------------
//
// --------------------------------------------------------

// msgDeleteService defines a state transition to delete a service.
type msgDeleteService struct {
Hash hash.Hash `json:"hash"`
cdc *codec.Codec
}

// newMsgDeleteService is a constructor function for msgSetService.
func newMsgDeleteService(cdc *codec.Codec, hash hash.Hash) *msgDeleteService {
return &msgDeleteService{
Hash: hash,
cdc: cdc,
}
}

// Route should return the name of the module.
func (msg msgDeleteService) Route() string {
return backendName
}

// Type returns the action.
func (msg msgDeleteService) Type() string {
return "delete_service"
}

// ValidateBasic runs stateless checks on the message.
func (msg msgDeleteService) ValidateBasic() cosmostypes.Error {
// if msg.Owner.Empty() {
// return cosmostypes.ErrInvalidAddress(msg.Owner.String())
// }
return nil
}

// GetSignBytes encodes the message for signing.
func (msg msgDeleteService) GetSignBytes() []byte {
return cosmostypes.MustSortJSON(msg.cdc.MustMarshalJSON(msg))
}

// GetSigners defines whose signature is required.
func (msg msgDeleteService) GetSigners() []cosmostypes.AccAddress {
return []cosmostypes.AccAddress{}
}
9 changes: 0 additions & 9 deletions sdk/service/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ func (s *SDK) Create(req *api.CreateServiceRequest, accountName, accountPassword
return s.Get(tx.Data)
}

// Delete deletes the service by hash.
func (s *SDK) Delete(hash hash.Hash, accountName, accountPassword string) error {
// TODO: pass account by parameters
accNumber, accSeq := uint64(0), uint64(0)
msg := newMsgDeleteService(s.cdc, hash)
_, err := s.client.BuildAndBroadcastMsg(msg, accountName, accountPassword, accNumber, accSeq)
return err
}

// Get returns the service that matches given hash.
func (s *SDK) Get(hash hash.Hash) (*service.Service, error) {
var service service.Service
Expand Down
Loading

0 comments on commit 034602b

Please sign in to comment.