From f57c564a4bb04bbaa66765f608fb216ac843df16 Mon Sep 17 00:00:00 2001 From: Angelo De Caro Date: Fri, 16 Jul 2021 05:43:17 +0200 Subject: [PATCH] bug fix #76 #77 - [x] network/channel support for IsTxFinal #77 - [x] nwo: fabric platform's Name() does not return the topology name #76 Signed-off-by: Angelo De Caro --- go.mod | 2 +- go.sum | 6 ++-- integration/fabric/atsa/chaincode/client.go | 3 +- integration/fabric/atsa/fsc/client/client.go | 7 ++-- integration/nwo/api/api.go | 3 +- integration/nwo/fabric/fabric.go | 2 +- pkg/api/client.go | 33 ++++++++++++++++- pkg/node/node.go | 8 +++-- .../fabric/core/generic/chaincode/invoke.go | 2 +- .../fabric/core/generic/finality/handler.go | 31 +++++++++------- .../fabric/core/generic/rwset/envelope.go | 10 +++--- .../fabric/core/generic/rwset/processor.go | 3 +- platform/fabric/core/provider.go | 5 +-- platform/fabric/sdk/sdk.go | 1 + platform/view/sdk/sdk.go | 24 ++++++------- platform/view/services/client/view/client.go | 12 +++++-- platform/view/services/client/web/client.go | 3 +- .../server/view/protos/commands.pb.go | 9 +++-- .../server/view/protos/finality.pb.go | 36 +++++++++++-------- .../server/view/protos/finality.proto | 5 +-- .../services/server/view/protos/generate.go | 2 +- .../services/server/view/protos/service.pb.go | 15 ++++---- 22 files changed, 143 insertions(+), 79 deletions(-) diff --git a/go.mod b/go.mod index 6f34cd3d1..bee4c0548 100755 --- a/go.mod +++ b/go.mod @@ -66,7 +66,7 @@ require ( golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect golang.org/x/text v0.3.5 // indirect - golang.org/x/tools v0.1.4 // indirect + golang.org/x/tools v0.1.5 // indirect google.golang.org/genproto v0.0.0-20210201184850-646a494a81ea // indirect google.golang.org/grpc v1.35.0 google.golang.org/protobuf v1.25.0 diff --git a/go.sum b/go.sum index df57948b3..4fc7294d5 100644 --- a/go.sum +++ b/go.sum @@ -862,10 +862,8 @@ golang.org/x/tools v0.0.0-20200131233409-575de47986ce/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20201105001634-bc3cf281b174/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.4 h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs= -golang.org/x/tools v0.1.4 h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/integration/fabric/atsa/chaincode/client.go b/integration/fabric/atsa/chaincode/client.go index 48a86d41f..36e1bf4d9 100644 --- a/integration/fabric/atsa/chaincode/client.go +++ b/integration/fabric/atsa/chaincode/client.go @@ -9,12 +9,13 @@ package chaincode import ( "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/chaincode/views" "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common" + "github.com/hyperledger-labs/fabric-smart-client/pkg/api" "github.com/hyperledger-labs/fabric-smart-client/platform/view/view" ) type ViewClient interface { CallView(fid string, in []byte) (interface{}, error) - IsTxFinal(txid string) error + IsTxFinal(txid string, opts ...api.ServiceOption) error } type Client struct { diff --git a/integration/fabric/atsa/fsc/client/client.go b/integration/fabric/atsa/fsc/client/client.go index d3d3efcbb..fb2775097 100644 --- a/integration/fabric/atsa/fsc/client/client.go +++ b/integration/fabric/atsa/fsc/client/client.go @@ -10,12 +10,13 @@ import ( "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/states" "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/views" "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common" + "github.com/hyperledger-labs/fabric-smart-client/pkg/api" "github.com/hyperledger-labs/fabric-smart-client/platform/view/view" ) type ViewClient interface { CallView(fid string, in []byte) (interface{}, error) - IsTxFinal(txid string) error + IsTxFinal(txid string, opts ...api.ServiceOption) error } type Client struct { @@ -79,6 +80,6 @@ func (c *Client) Transfer(assetID string, agreementID string, recipient view.Ide return nil } -func (c *Client) IsTxFinal(id string) error { - return c.c.IsTxFinal(id) +func (c *Client) IsTxFinal(id string, opts ...api.ServiceOption) error { + return c.c.IsTxFinal(id, opts...) } diff --git a/integration/nwo/api/api.go b/integration/nwo/api/api.go index 138a3a4d2..f19300745 100644 --- a/integration/nwo/api/api.go +++ b/integration/nwo/api/api.go @@ -11,6 +11,7 @@ import ( "gopkg.in/yaml.v2" "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/identity" + "github.com/hyperledger-labs/fabric-smart-client/pkg/api" "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/view" "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc" ) @@ -73,7 +74,7 @@ type Builder interface { type ViewClient interface { CallView(fid string, in []byte) (interface{}, error) - IsTxFinal(txid string) error + IsTxFinal(txid string, opts ...api.ServiceOption) error } type Platform interface { diff --git a/integration/nwo/fabric/fabric.go b/integration/nwo/fabric/fabric.go index 3d6ffa87d..969692629 100644 --- a/integration/nwo/fabric/fabric.go +++ b/integration/nwo/fabric/fabric.go @@ -84,7 +84,7 @@ func NewPlatform(context api.Context, t api.Topology, components BuilderClient) } func (p *platform) Name() string { - return "default" + return p.Topology().Name() } func (p *platform) Type() string { diff --git a/pkg/api/client.go b/pkg/api/client.go index 2819149f1..4e569ac6a 100644 --- a/pkg/api/client.go +++ b/pkg/api/client.go @@ -6,6 +6,37 @@ SPDX-License-Identifier: Apache-2.0 package api +type ServiceOptions struct { + Network string + Channel string +} + +func CompileServiceOptions(opts ...ServiceOption) (*ServiceOptions, error) { + txOptions := &ServiceOptions{} + for _, opt := range opts { + if err := opt(txOptions); err != nil { + return nil, err + } + } + return txOptions, nil +} + +type ServiceOption func(*ServiceOptions) error + +func WithNetwork(network string) ServiceOption { + return func(o *ServiceOptions) error { + o.Network = network + return nil + } +} + +func WithChannel(channel string) ServiceOption { + return func(o *ServiceOptions) error { + o.Channel = channel + return nil + } +} + type ViewClient interface { // CallView takes in input a view factory identifier, fid, and an input, in, and invokes the // factory f bound to fid on input in. The view returned by the factory is invoked on @@ -25,5 +56,5 @@ type ViewClient interface { // IsTxFinal takes in input a transaction id and return nil if the transaction has been committed, // an error otherwise. - IsTxFinal(txid string) error + IsTxFinal(txid string, opts ...ServiceOption) error } diff --git a/pkg/node/node.go b/pkg/node/node.go index 0f90781f7..1d1d58b98 100755 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -152,8 +152,12 @@ func (n *node) ResolveIdentities(endpoints ...string) ([]view.Identity, error) { return ids, nil } -func (n *node) IsTxFinal(txid string) error { - return fabric.GetDefaultChannel(n.registry).Finality().IsFinal(txid) +func (n *node) IsTxFinal(txid string, opts ...api.ServiceOption) error { + options, err := api.CompileServiceOptions(opts...) + if err != nil { + return err + } + return fabric.GetChannel(n.registry, options.Network, options.Channel).Finality().IsFinal(txid) } func (n *node) CallView(fid string, in []byte) (interface{}, error) { diff --git a/platform/fabric/core/generic/chaincode/invoke.go b/platform/fabric/core/generic/chaincode/invoke.go index e06fcab0a..5b9ddce1e 100644 --- a/platform/fabric/core/generic/chaincode/invoke.go +++ b/platform/fabric/core/generic/chaincode/invoke.go @@ -175,7 +175,7 @@ func (i *Invoke) Call() (interface{}, error) { // collect responses responses, err := i.collectResponses(endorserClients, signedProp) if err != nil { - return nil, errors.WithMessagef(err, "error endorsing") + return nil, errors.Wrapf(err, "failed collecting proposal responses") } if len(responses) == 0 { diff --git a/platform/fabric/core/generic/finality/handler.go b/platform/fabric/core/generic/finality/handler.go index 5577d8c24..cbbf9f98e 100644 --- a/platform/fabric/core/generic/finality/handler.go +++ b/platform/fabric/core/generic/finality/handler.go @@ -12,6 +12,7 @@ import ( "github.com/pkg/errors" + "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver" view2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view" protos2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view/protos" ) @@ -20,33 +21,39 @@ type Server interface { RegisterProcessor(typ reflect.Type, p view2.Processor) } +type NetworkProvider interface { + FabricNetworkService(network string) (driver.FabricNetworkService, error) +} + type finalityHandler struct { - network Network + networkProvider NetworkProvider } -func InstallHandler(server Server, network Network) { - fh := &finalityHandler{network: network} +func InstallHandler(server Server, networkProvider NetworkProvider) { + fh := &finalityHandler{networkProvider: networkProvider} server.RegisterProcessor(reflect.TypeOf(&protos2.Command_IsTxFinal{}), fh.isTxFinal) } func (s *finalityHandler) isTxFinal(ctx context.Context, command *protos2.Command) (interface{}, error) { - isTxFinalCommand := command.Payload.(*protos2.Command_IsTxFinal).IsTxFinal + c := command.Payload.(*protos2.Command_IsTxFinal).IsTxFinal - logger.Debugf("Answering: Is [%s] final?", isTxFinalCommand.Txid) + logger.Debugf("Answering: Is [%s] final on [%s:%s]?", c.Txid, c.Network, c.Channel) - ch, err := s.network.Channel(isTxFinalCommand.Channel) + network, err := s.networkProvider.FabricNetworkService(c.Network) if err != nil { - return nil, errors.Errorf("failed getting finality service for channel [%s], err [%s]", isTxFinalCommand.Channel, err) + return nil, errors.Errorf("failed getting network [%s], err [%s]", c.Network, err) } - - err = ch.IsFinal(isTxFinalCommand.Txid) + ch, err := network.Channel(c.Channel) if err != nil { - logger.Debugf("Answering: Is [%s] final? No", isTxFinalCommand.Txid) + return nil, errors.Errorf("failed getting finality service for channel [%s], err [%s]", c.Channel, err) + } + err = ch.IsFinal(c.Txid) + if err != nil { + logger.Debugf("Answering: Is [%s] final on [%s:%s]? No", c.Txid, c.Network, c.Channel) return &protos2.CommandResponse_IsTxFinalResponse{IsTxFinalResponse: &protos2.IsTxFinalResponse{ Payload: []byte(err.Error()), }}, nil } - - logger.Debugf("Answering: Is [%s] final? Yes", isTxFinalCommand.Txid) + logger.Debugf("Answering: Is [%s] final on [%s:%s]? Yes", c.Txid, c.Network, c.Channel) return &protos2.CommandResponse_IsTxFinalResponse{IsTxFinalResponse: &protos2.IsTxFinalResponse{}}, nil } diff --git a/platform/fabric/core/generic/rwset/envelope.go b/platform/fabric/core/generic/rwset/envelope.go index daa99e9f0..9956760fb 100644 --- a/platform/fabric/core/generic/rwset/envelope.go +++ b/platform/fabric/core/generic/rwset/envelope.go @@ -16,6 +16,7 @@ import ( ) type UnpackedEnvelope struct { + NetworkID string TxID string Ch string ChaincodeName string @@ -31,15 +32,15 @@ type UnpackedEnvelope struct { ProposalResponses []*peer.ProposalResponse } -func UnpackEnvelopeFromBytes(raw []byte) (*UnpackedEnvelope, error) { +func UnpackEnvelopeFromBytes(networkID string, raw []byte) (*UnpackedEnvelope, error) { env := &common.Envelope{} if err := proto.Unmarshal(raw, env); err != nil { return nil, err } - return UnpackEnvelope(env) + return UnpackEnvelope(networkID, env) } -func UnpackEnvelope(env *common.Envelope) (*UnpackedEnvelope, error) { +func UnpackEnvelope(networkID string, env *common.Envelope) (*UnpackedEnvelope, error) { payl, err := protoutil.UnmarshalPayload(env.Payload) if err != nil { logger.Errorf("VSCC error: GetPayload failed, err %s", err) @@ -115,6 +116,7 @@ func UnpackEnvelope(env *common.Envelope) (*UnpackedEnvelope, error) { } return &UnpackedEnvelope{ + NetworkID: networkID, TxID: chdr.TxId, Ch: chdr.ChannelId, ChaincodeName: cis.ChaincodeSpec.ChaincodeId.Name, @@ -136,7 +138,7 @@ func (u *UnpackedEnvelope) ID() string { } func (u *UnpackedEnvelope) Network() string { - return "" + return u.NetworkID } func (u *UnpackedEnvelope) Channel() string { diff --git a/platform/fabric/core/generic/rwset/processor.go b/platform/fabric/core/generic/rwset/processor.go index 8ec4be1eb..f1b5a625d 100644 --- a/platform/fabric/core/generic/rwset/processor.go +++ b/platform/fabric/core/generic/rwset/processor.go @@ -22,6 +22,7 @@ var logger = flogging.MustGetLogger("fabric-sdk.rwset") type Network interface { Channel(name string) (driver.Channel, error) TransactionManager() driver.TransactionManager + Name() string } type RWSExtractor interface { @@ -132,7 +133,7 @@ func (r *processorManager) getTxFromEvn(ch driver.Channel, txid string) (driver. return nil, nil, errors.Wrapf(err, "failed unmarshalling envelope [%s]", txid) } logger.Debugf("unpack envelope [%s,%s]", ch.Name(), txid) - upe, err := UnpackEnvelope(env) + upe, err := UnpackEnvelope(r.network.Name(), env) if err != nil { return nil, nil, errors.Wrapf(err, "failed unpacking envelope [%s]", txid) } diff --git a/platform/fabric/core/provider.go b/platform/fabric/core/provider.go index bd7352533..7b1ee1489 100644 --- a/platform/fabric/core/provider.go +++ b/platform/fabric/core/provider.go @@ -58,6 +58,9 @@ func (p *fnsProvider) Start(ctx context.Context) error { } } } + + finality.InstallHandler(view3.GetService(p.sp), p) + return nil } @@ -142,8 +145,6 @@ func (p *fnsProvider) newFNS(network string) (driver.FabricNetworkService, error return nil, errors.Wrap(err, "failed instantiating fabric service provider") } - finality.InstallHandler(view3.GetService(p.sp), net) - return net, nil } diff --git a/platform/fabric/sdk/sdk.go b/platform/fabric/sdk/sdk.go index 841d8ff69..19b990fce 100644 --- a/platform/fabric/sdk/sdk.go +++ b/platform/fabric/sdk/sdk.go @@ -61,6 +61,7 @@ func (p *p) Install() error { p.fnsProvider, err = core.NewFabricNetworkServiceProvider(p.registry, fnspConfig) assert.NoError(err, "failed instantiating fabric network service provider") assert.NoError(p.registry.RegisterService(p.fnsProvider)) + assert.NoError(fabric2.GetDefaultFNS(p.registry).ProcessorManager().SetDefaultProcessor( state.NewRWSetProcessor(fabric2.GetDefaultFNS(p.registry)), )) diff --git a/platform/view/sdk/sdk.go b/platform/view/sdk/sdk.go index 15b34b42d..ddc48d4a7 100644 --- a/platform/view/sdk/sdk.go +++ b/platform/view/sdk/sdk.go @@ -104,7 +104,7 @@ func (p *p) Install() error { // View Service Server marshaller, err := view2.NewResponseMarshaler(p.registry) if err != nil { - return fmt.Errorf("error creating view service response marshaller: %webServer", err) + return fmt.Errorf("error creating view service response marshaller: %s", err) } p.viewService, err = view2.NewViewServiceServer(marshaller, @@ -114,7 +114,7 @@ func (p *p) Install() error { ), ) if err != nil { - return fmt.Errorf("error creating view service server: %webServer", err) + return fmt.Errorf("error creating view service server: %s", err) } if err := p.registry.RegisterService(p.viewService); err != nil { return err @@ -150,7 +150,7 @@ func (p *p) Start(ctx context.Context) error { assert.NoError(p.registerViewServiceServer(), "failed registering view service server") assert.NoError(p.startViewManager(), "failed starting view manager") - logger.Infof("Started peer with ID=[%webServer], network ID=[%webServer], address=[%webServer]", view.GetConfigService(p.registry).GetString("fsc.id")) + logger.Infof("Started peer with ID=[%s], network ID=[%s], address=[%s]", view.GetConfigService(p.registry).GetString("fsc.id")) return p.serve() } @@ -204,7 +204,7 @@ func (p *p) initGRPCServer() error { listenAddr := configProvider.GetString("fsc.listenAddress") serverConfig, err := p.getServerConfig() if err != nil { - logger.Fatalf("Error loading secure config for peer (%webServer)", err) + logger.Fatalf("Error loading secure config for peer (%s)", err) } serverConfig.Logger = flogging.MustGetLogger("core.comm").With("server", "PeerServer") @@ -225,7 +225,7 @@ func (p *p) initGRPCServer() error { // set the cert to use if client auth is requested by remote endpoints clientCert, err := p.getClientCertificate() if err != nil { - logger.Fatalf("Failed to set TLS client certificate (%webServer)", err) + logger.Fatalf("Failed to set TLS client certificate (%s)", err) } cs.SetClientCertificate(clientCert) } @@ -267,7 +267,7 @@ func (p *p) serve() error { go func() { logger.Info("Starting GRPC server...") if err := p.grpcServer.Start(); err != nil { - logger.Fatalf("grpc server stopped with err [%webServer]", err) + logger.Fatalf("grpc server stopped with err [%s]", err) } }() go func() { @@ -285,7 +285,7 @@ func (p *p) serve() error { if p.webServer != nil { logger.Info("web server stopping...") if err := p.webServer.Stop(); err != nil { - logger.Errorf("failed stopping web server [%webServer]", err) + logger.Errorf("failed stopping web server [%s]", err) } } logger.Info("web server stopping...done") @@ -316,7 +316,7 @@ func (p *p) getLocalAddress() (string, error) { localIP, err := grpc2.GetLocalIP() if err != nil { - logger.Errorf("local IP address not auto-detectable: %webServer", err) + logger.Errorf("local IP address not auto-detectable: %s", err) return "", err } autoDetectedIPAndPort := net.JoinHostPort(localIP, port) @@ -349,11 +349,11 @@ func (p *p) getServerConfig() (grpc2.ServerConfig, error) { // get the certs from the file system serverKey, err := ioutil.ReadFile(configProvider.GetPath("fsc.tls.key.file")) if err != nil { - return serverConfig, fmt.Errorf("error loading TLS key (%webServer)", err) + return serverConfig, fmt.Errorf("error loading TLS key (%s)", err) } serverCert, err := ioutil.ReadFile(configProvider.GetPath("fsc.tls.cert.file")) if err != nil { - return serverConfig, fmt.Errorf("error loading TLS certificate (%webServer)", err) + return serverConfig, fmt.Errorf("error loading TLS certificate (%s)", err) } serverConfig.SecOpts.Certificate = serverCert serverConfig.SecOpts.Key = serverKey @@ -363,7 +363,7 @@ func (p *p) getServerConfig() (grpc2.ServerConfig, error) { for _, file := range configProvider.GetStringSlice("fsc.tls.clientRootCAs.files") { clientRoot, err := ioutil.ReadFile(configProvider.TranslatePath(file)) if err != nil { - return serverConfig, fmt.Errorf("error loading client root CAs (%webServer)", err) + return serverConfig, fmt.Errorf("error loading client root CAs (%s)", err) } clientRoots = append(clientRoots, clientRoot) } @@ -373,7 +373,7 @@ func (p *p) getServerConfig() (grpc2.ServerConfig, error) { if configProvider.GetPath("fsc.tls.rootcert.file") != "" { rootCert, err := ioutil.ReadFile(configProvider.GetPath("fsc.tls.rootcert.file")) if err != nil { - return serverConfig, fmt.Errorf("error loading TLS root certificate (%webServer)", err) + return serverConfig, fmt.Errorf("error loading TLS root certificate (%s)", err) } serverConfig.SecOpts.ServerRootCAs = [][]byte{rootCert} } diff --git a/platform/view/services/client/view/client.go b/platform/view/services/client/view/client.go index f5bdade58..71d3c42b1 100644 --- a/platform/view/services/client/view/client.go +++ b/platform/view/services/client/view/client.go @@ -18,6 +18,7 @@ import ( "github.com/pkg/errors" "google.golang.org/grpc" + "github.com/hyperledger-labs/fabric-smart-client/pkg/api" "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging" protos2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view/protos" @@ -131,10 +132,17 @@ func (s *client) Track(cid string) string { panic("implement me") } -func (s *client) IsTxFinal(txid string) error { +func (s *client) IsTxFinal(txid string, opts ...api.ServiceOption) error { + options, err := api.CompileServiceOptions(opts...) + if err != nil { + return err + } + logger.Debugf("Calling IsTxFinal on txid [%s]", txid) payload := &protos2.Command_IsTxFinal{IsTxFinal: &protos2.IsTxFinal{ - Txid: txid, + Network: options.Network, + Channel: options.Channel, + Txid: txid, }} sc, err := s.CreateSignedCommand(payload, s.SigningIdentity) if err != nil { diff --git a/platform/view/services/client/web/client.go b/platform/view/services/client/web/client.go index d9e7b92d0..c6009fbc7 100644 --- a/platform/view/services/client/web/client.go +++ b/platform/view/services/client/web/client.go @@ -15,6 +15,7 @@ import ( "io/ioutil" "net/http" + "github.com/hyperledger-labs/fabric-smart-client/pkg/api" protos2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view/protos" ) @@ -103,6 +104,6 @@ func (c *Client) Track(cid string) string { panic("implement me") } -func (c *Client) IsTxFinal(txid string) error { +func (c *Client) IsTxFinal(txid string, opts ...api.ServiceOption) error { panic("implement me") } diff --git a/platform/view/services/server/view/protos/commands.pb.go b/platform/view/services/server/view/protos/commands.pb.go index aa81c7a0a..d0ba502ff 100644 --- a/platform/view/services/server/view/protos/commands.pb.go +++ b/platform/view/services/server/view/protos/commands.pb.go @@ -4,11 +4,10 @@ package protos import ( - "fmt" - "math" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes/timestamp" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + timestamp "github.com/golang/protobuf/ptypes/timestamp" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/platform/view/services/server/view/protos/finality.pb.go b/platform/view/services/server/view/protos/finality.pb.go index c241d7ae0..f901bacec 100644 --- a/platform/view/services/server/view/protos/finality.pb.go +++ b/platform/view/services/server/view/protos/finality.pb.go @@ -4,10 +4,9 @@ package protos import ( - "fmt" - "math" - - "github.com/golang/protobuf/proto" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,8 +21,9 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type IsTxFinal struct { - Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` - Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` + Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` + Channel string `protobuf:"bytes,2,opt,name=channel,proto3" json:"channel,omitempty"` + Txid string `protobuf:"bytes,3,opt,name=txid,proto3" json:"txid,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -54,6 +54,13 @@ func (m *IsTxFinal) XXX_DiscardUnknown() { var xxx_messageInfo_IsTxFinal proto.InternalMessageInfo +func (m *IsTxFinal) GetNetwork() string { + if m != nil { + return m.Network + } + return "" +} + func (m *IsTxFinal) GetChannel() string { if m != nil { return m.Channel @@ -115,14 +122,15 @@ func init() { func init() { proto.RegisterFile("finality.proto", fileDescriptor_0144d353a635b215) } var fileDescriptor_0144d353a635b215 = []byte{ - // 130 bytes of a gzipped FileDescriptorProto + // 145 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0xcb, 0xcc, 0x4b, 0xcc, 0xc9, 0x2c, 0xa9, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x03, 0x53, 0xc5, 0x4a, - 0x96, 0x5c, 0x9c, 0x9e, 0xc5, 0x21, 0x15, 0x6e, 0x20, 0x59, 0x21, 0x09, 0x2e, 0xf6, 0xe4, 0x8c, - 0xc4, 0xbc, 0xbc, 0xd4, 0x1c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x18, 0x57, 0x48, 0x88, - 0x8b, 0xa5, 0xa4, 0x22, 0x33, 0x45, 0x82, 0x09, 0x2c, 0x0c, 0x66, 0x2b, 0xe9, 0x72, 0x09, 0xc2, - 0xb5, 0x06, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x82, 0x8c, 0x28, 0x48, 0xac, 0xcc, 0xc9, - 0x4f, 0x4c, 0x01, 0x1b, 0xc1, 0x13, 0x04, 0xe3, 0x3a, 0x71, 0x47, 0x41, 0xed, 0x6c, 0x60, 0x64, - 0x4c, 0x82, 0x30, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xc1, 0x00, 0xe3, 0x97, 0x00, - 0x00, 0x00, + 0xc1, 0x5c, 0x9c, 0x9e, 0xc5, 0x21, 0x15, 0x6e, 0x20, 0x59, 0x21, 0x09, 0x2e, 0xf6, 0xbc, 0xd4, + 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x18, 0x17, 0x24, 0x93, + 0x9c, 0x91, 0x98, 0x97, 0x97, 0x9a, 0x23, 0xc1, 0x04, 0x91, 0x81, 0x72, 0x85, 0x84, 0xb8, 0x58, + 0x4a, 0x2a, 0x32, 0x53, 0x24, 0x98, 0xc1, 0xc2, 0x60, 0xb6, 0x92, 0x2e, 0x97, 0x20, 0xdc, 0xd0, + 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x90, 0x11, 0x05, 0x89, 0x95, 0x39, 0xf9, 0x89, + 0x29, 0x60, 0xc3, 0x79, 0x82, 0x60, 0x5c, 0x27, 0xee, 0x28, 0xa8, 0x6b, 0x1a, 0x18, 0x19, 0x93, + 0x20, 0x4c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0xaf, 0xf1, 0x45, 0xb1, 0x00, 0x00, + 0x00, } diff --git a/platform/view/services/server/view/protos/finality.proto b/platform/view/services/server/view/protos/finality.proto index a4498b582..ced02d975 100644 --- a/platform/view/services/server/view/protos/finality.proto +++ b/platform/view/services/server/view/protos/finality.proto @@ -12,8 +12,9 @@ option cc_generic_services = true; package protos; message IsTxFinal { - string channel = 1; - string txid = 2; + string network = 1; + string channel = 2; + string txid = 3; } message IsTxFinalResponse { diff --git a/platform/view/services/server/view/protos/generate.go b/platform/view/services/server/view/protos/generate.go index f9b33b1d1..6e20d3e8e 100644 --- a/platform/view/services/server/view/protos/generate.go +++ b/platform/view/services/server/view/protos/generate.go @@ -6,4 +6,4 @@ SPDX-License-Identifier: Apache-2.0 package protos -//go:generate protoc commands.proto finality.proto service.proto --go_out=plugins=grpc:. +//go:generate protoc commands.proto finality.proto service.proto --go_out=plugins=grpc,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp:. diff --git a/platform/view/services/server/view/protos/service.pb.go b/platform/view/services/server/view/protos/service.pb.go index e4d6caea6..9864dec39 100644 --- a/platform/view/services/server/view/protos/service.pb.go +++ b/platform/view/services/server/view/protos/service.pb.go @@ -4,14 +4,13 @@ package protos import ( - "context" - "fmt" - "math" - - "github.com/golang/protobuf/proto" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" ) // Reference imports to suppress errors if they are not otherwise used.