This is an automated email from the ASF dual-hosted git repository.

cmorris pushed a commit to branch splitroles-blockchain
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git

commit 8a626097dd6f3994f88bb362be80c9814f94f595
Author: Christopher Morris <[email protected]>
AuthorDate: Mon Sep 30 10:43:38 2019 +0100

    Remove BC reference to order method
---
 pkg/api/client.go             | 18 ++----------
 pkg/defaultservice/fulfill.go | 64 +------------------------------------------
 pkg/defaultservice/service.go |  1 +
 pkg/endpoints/endpoints.go    | 11 +-------
 pkg/service/service.go        |  3 +-
 pkg/tendermint/tendermint.go  | 11 +++++++-
 6 files changed, 16 insertions(+), 92 deletions(-)

diff --git a/pkg/api/client.go b/pkg/api/client.go
index 45ee0d3..198d466 100644
--- a/pkg/api/client.go
+++ b/pkg/api/client.go
@@ -34,8 +34,7 @@ var (
 
 //ClientService - enables service to be mocked
 type ClientService interface {
-       BCFulfillOrder(tx *BlockChainTX) (string, error)
-       FulfillOrder(req *FulfillOrderRequest) (*FulfillOrderResponse, error)
+       FulfillOrder(tx *BlockChainTX) (string, error)
        FulfillOrderSecret(req *FulfillOrderSecretRequest) 
(*FulfillOrderSecretResponse, error)
        Status(token string) (*StatusResponse, error)
        Dump(tx *BlockChainTX) error
@@ -76,19 +75,6 @@ func NewHTTPClient(instance string, logger *logger.Logger) 
(ClientService, error
 
 }
 
-//FulfillOrder -
-func (c MilagroClientService) FulfillOrder(req *FulfillOrderRequest) 
(*FulfillOrderResponse, error) {
-       endpoint := c.endpoints["FulfillOrder"]
-       ctx := context.Background()
-
-       d, err := endpoint(ctx, req)
-       if err != nil {
-               return nil, err
-       }
-       r := d.(*FulfillOrderResponse)
-       return r, nil
-}
-
 //FulfillOrderSecret -
 func (c MilagroClientService) FulfillOrderSecret(req 
*FulfillOrderSecretRequest) (*FulfillOrderSecretResponse, error) {
        endpoint := c.endpoints["FulfillOrderSecret"]
@@ -116,7 +102,7 @@ func (c MilagroClientService) Status(token string) 
(*StatusResponse, error) {
        return r, nil
 }
 
-func (c MilagroClientService) BCFulfillOrder(tx *BlockChainTX) (string, error) 
{
+func (c MilagroClientService) FulfillOrder(tx *BlockChainTX) (string, error) {
        return "", nil
 }
 
diff --git a/pkg/defaultservice/fulfill.go b/pkg/defaultservice/fulfill.go
index 0aad725..2857bef 100644
--- a/pkg/defaultservice/fulfill.go
+++ b/pkg/defaultservice/fulfill.go
@@ -29,7 +29,7 @@ import (
        "github.com/apache/incubator-milagro-dta/pkg/tendermint"
 )
 
-func (s *Service) BCFulfillOrder(tx *api.BlockChainTX) (string, error) {
+func (s *Service) FulfillOrder(tx *api.BlockChainTX) (string, error) {
 
        reqPayload := tx.Payload
        txHashString := hex.EncodeToString(tx.TXhash)
@@ -113,68 +113,6 @@ func (s *Service) BCFulfillOrder(tx *api.BlockChainTX) 
(string, error) {
 
 }
 
-// FulfillOrder -
-func (s *Service) FulfillOrder(req *api.FulfillOrderRequest) (string, error) {
-       orderPart1CID := req.OrderPart1CID
-       nodeID := s.NodeID()
-       remoteIDDocCID := req.DocumentCID
-       _, _, _, sikeSK, err := common.RetrieveIdentitySecrets(s.Store, nodeID)
-       if err != nil {
-               return "", err
-       }
-
-       remoteIDDoc, err := common.RetrieveIDDocFromIPFS(s.Ipfs, remoteIDDocCID)
-       if err != nil {
-               return "", err
-       }
-
-       //Retrieve the order from IPFS
-       order, err := common.RetrieveOrderFromIPFS(s.Ipfs, orderPart1CID, 
sikeSK, nodeID, remoteIDDoc.BLSPublicKey)
-       if err != nil {
-               return "", err
-       }
-
-       recipientList, err := common.BuildRecipientList(s.Ipfs, 
order.PrincipalCID, nodeID)
-       if err != nil {
-               return "", err
-       }
-
-       //Generate the secret and store for later redemption
-       seed, err := common.MakeRandomSeedAndStore(s.Store, s.Rng, 
order.Reference)
-       if err != nil {
-               return "", err
-       }
-
-       //Generate the Public Key (Commitment) from the Seed/Secret
-       commitmentPublicKey, err := cryptowallet.RedeemPublicKey(seed)
-       if err != nil {
-               return "", err
-       }
-
-       //Create an order response in IPFS
-       orderPart2CID, err := common.CreateAndStoreOrderPart2(s.Ipfs, s.Store, 
order, orderPart1CID, commitmentPublicKey, nodeID, recipientList)
-       if err != nil {
-               return "", err
-       }
-
-       response := &api.FulfillOrderResponse{
-               OrderPart2CID: orderPart2CID,
-       }
-
-       marshaledRequest, _ := json.Marshal(response)
-
-       //Write the requests to the chain
-       chainTX := &api.BlockChainTX{
-               Processor:   api.TXFulfillResponse,
-               SenderID:    nodeID,
-               RecipientID: []string{order.PrincipalCID, nodeID},
-               Payload:     marshaledRequest,
-               Tags:        map[string]string{"reference": order.Reference},
-       }
-       return tendermint.PostToChain(chainTX, "FulfillOrder")
-
-}
-
 // FulfillOrderSecret -
 func (s *Service) FulfillOrderSecret(req *api.FulfillOrderSecretRequest) 
(string, error) {
        //Initialise values from Request object
diff --git a/pkg/defaultservice/service.go b/pkg/defaultservice/service.go
index 9d1bc4f..76101e9 100644
--- a/pkg/defaultservice/service.go
+++ b/pkg/defaultservice/service.go
@@ -118,6 +118,7 @@ func (s *Service) Status(apiVersion, nodeType string) 
(*api.StatusResponse, erro
        }, nil
 }
 
+//Dump - used for debugging purpose, print the entire Encrypted Transaction
 func (s *Service) Dump(tx *api.BlockChainTX) error {
        nodeID := s.NodeID()
        txHashString := hex.EncodeToString(tx.TXhash)
diff --git a/pkg/endpoints/endpoints.go b/pkg/endpoints/endpoints.go
index eb9a385..05758f6 100644
--- a/pkg/endpoints/endpoints.go
+++ b/pkg/endpoints/endpoints.go
@@ -383,16 +383,7 @@ func MakeOrderSecret2Endpoint(m service.Service) 
endpoint.Endpoint {
 
 //MakeFulfillOrderEndpoint -
 func MakeFulfillOrderEndpoint(m service.Service) endpoint.Endpoint {
-       return func(ctx context.Context, request interface{}) (response 
interface{}, err error) {
-               req, ok := request.(*api.FulfillOrderRequest)
-               if !ok {
-                       return nil, transport.ErrInvalidRequest
-               }
-               if err := validateRequest(req); err != nil {
-                       return "", err
-               }
-               return m.FulfillOrder(req)
-       }
+       return nil
 }
 
 //MakeFulfillOrderSecretEndpoint -
diff --git a/pkg/service/service.go b/pkg/service/service.go
index c585584..26c3189 100644
--- a/pkg/service/service.go
+++ b/pkg/service/service.go
@@ -41,8 +41,7 @@ type Service interface {
        Order2(tx *api.BlockChainTX) (string, error)
 
        //Fullfill processing
-       BCFulfillOrder(tx *api.BlockChainTX) (string, error)
-       FulfillOrder(req *api.FulfillOrderRequest) (string, error)
+       FulfillOrder(tx *api.BlockChainTX) (string, error)
        FulfillOrderSecret(req *api.FulfillOrderSecretRequest) (string, error)
 
        NodeID() string
diff --git a/pkg/tendermint/tendermint.go b/pkg/tendermint/tendermint.go
index 846c13f..6c7eeee 100644
--- a/pkg/tendermint/tendermint.go
+++ b/pkg/tendermint/tendermint.go
@@ -130,7 +130,7 @@ func callNextTX(svc service.Service, tx *api.BlockChainTX, 
listenPort string) er
                return nil
        }
        if tx.Processor == "v1/fulfill/order" {
-               svc.BCFulfillOrder(tx)
+               svc.FulfillOrder(tx)
                return nil
        }
        if tx.Processor == "v1/order2" {
@@ -138,6 +138,15 @@ func callNextTX(svc service.Service, tx *api.BlockChainTX, 
listenPort string) er
                return nil
        }
 
+       // if tx.Processor == "v1/fulfill/order/secret" {
+       //      svc.FulfillOrderSecret(tx)
+       //      return nil
+       // }
+       // if tx.Processor == "v1/order/secret2" {
+       //      svc.OrderSecret1(tx)
+       //      return nil
+       // }
+
        desintationURL := fmt.Sprintf("http://localhost"+listenPort+"/%s";, 
tx.Processor)
 
        body := strings.NewReader(payloadString)

Reply via email to