Skip to content
2 changes: 1 addition & 1 deletion integration/fabricx/simple/views/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
)

Expand Down
7 changes: 3 additions & 4 deletions integration/fabricx/simple/views/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import (

"github.com/hyperledger-labs/fabric-smart-client/integration/fabricx/simple/views/utils"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
fdriver "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/finality"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
)

Expand Down Expand Up @@ -68,12 +67,12 @@ func (i *CreateView) Call(viewCtx view.Context) (interface{}, error) {
}

// create a listener go check when the tx is committed
network, ch, err := fabric.GetDefaultChannel(viewCtx)
network, err := fabricx.GetDefaultFNS(viewCtx)
if err != nil {
return nil, err
}

lm, err := finality.GetListenerManager(viewCtx, network.Name(), ch.Name())
lm, err := network.FinalityService()
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion integration/fabricx/simple/views/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
)

Expand Down
4 changes: 4 additions & 0 deletions integration/nwo/fabricx/extensions/scv2/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const (
endpoint:
host: localhost
port: 7001
keep-alive:
params:
time: 60s
timeout 600s
database:
host: localhost
port: 5433
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/fabricx/extensions/scv2/ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (e *Extension) CheckTopology() {

func (e *Extension) GenerateArtifacts() {
generateQSExtension(e.network)
generateNSExtension(e.network)
generateNSExtension(e.network, e.sidecar.Ports[fabric_network.ListenPort])
}

func (e *Extension) PostRun(load bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

// generateNSExtensions adds the committers notification service information to the config
func generateNSExtension(n *network.Network) {
func generateNSExtension(n *network.Network, notificationServicePort uint16) {
context := n.Context

fscTop, ok := context.TopologyByName("fsc").(*fsc.Topology)
Expand All @@ -33,7 +33,6 @@ func generateNSExtension(n *network.Network) {

// TODO set correct values
notificationServiceHost := "localhost"
notificationServicePort := 5411

// TODO: most of this logic should go somewhere

Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/fabricx/extensions/scv2/queryservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabricx/network"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc"
)

Expand Down
4 changes: 4 additions & 0 deletions platform/fabric/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ func (s *ConfigService) GetString(key string) string {
func (s *ConfigService) DefaultChannel() string {
return s.confService.DefaultChannel()
}

func (s *ConfigService) UnmarshalKey(key string, rawVal interface{}) error {
return s.confService.UnmarshalKey(key, rawVal)
}
6 changes: 6 additions & 0 deletions platform/fabricx/core/finality/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
grpc2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
Expand All @@ -36,6 +37,11 @@ func GrpcClient(c *Config) (*grpc.ClientConn, error) {
var opts []grpc.DialOption
opts = append(opts, WithConnectionTime(endpoint.ConnectionTimeout))
opts = append(opts, WithTLS(endpoint))
opts = append(opts, grpc2.ClientKeepaliveOptions(
grpc2.KeepaliveOptions{
ClientInterval: 5 * time.Minute,
ClientTimeout: 6 * time.Minute,
})...)

return grpc.NewClient(endpoint.Address, opts...)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fabricx
package core

import (
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
grpc2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
Expand All @@ -36,6 +37,11 @@ func GrpcClient(c *Config) (*grpc.ClientConn, error) {
var opts []grpc.DialOption
opts = append(opts, WithConnectionTime(endpoint.ConnectionTimeout))
opts = append(opts, WithTLS(endpoint))
opts = append(opts, grpc2.ClientKeepaliveOptions(
grpc2.KeepaliveOptions{
ClientInterval: 120 * time.Second,
ClientTimeout: 600 * time.Second,
})...)

return grpc.NewClient(endpoint.Address, opts...)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
queryservice2 "github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestGRPC(t *testing.T) {
checks: func(t *testing.T, client *grpc.ClientConn, err error) {
t.Helper()
require.Nil(t, client)
require.ErrorIs(t, err, queryservice.ErrInvalidAddress)
require.ErrorIs(t, err, queryservice2.ErrInvalidAddress)
},
},
{
Expand Down Expand Up @@ -155,9 +155,9 @@ func TestGRPC(t *testing.T) {
t.Run(fmt.Sprintf("grpcClient %v", tc.name), func(t *testing.T) {
t.Parallel()
cs := newConfigService(tc.cfg)
c, err := queryservice.NewConfig(cs)
c, err := queryservice2.NewConfig(cs)
require.NoError(t, err)
client, err := queryservice.GrpcClient(c)
client, err := queryservice2.GrpcClient(c)
tc.checks(t, client, err)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/driver/config"
fdriver "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services"
"github.com/hyperledger/fabric-x-committer/api/protoqueryservice"
)
Expand All @@ -22,7 +21,7 @@ type QueryService interface {
GetStates(map[driver.Namespace][]driver.PKey) (map[driver.Namespace]map[driver.PKey]driver.VaultValue, error)
}

func NewRemoteQueryServiceFromConfig(configService fdriver.ConfigService) (*RemoteQueryService, error) {
func NewRemoteQueryServiceFromConfig(configService ConfigService) (*RemoteQueryService, error) {
c, err := NewConfig(configService)
if err != nil {
return nil, errors.Wrap(err, "get config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ func (s *RemoteQueryService) GetStates(m map[driver.Namespace][]driver.PKey) (ma
return s.query(m)
}

func (s *RemoteQueryService) GetTransactionStatus(txID string) (int32, error) {
ctx, cancel := context.WithTimeout(context.Background(), s.config.QueryTimeout)
defer cancel()

now := time.Now()
res, err := s.client.GetTransactionStatus(ctx, &protoqueryservice.TxStatusQuery{
TxIds: []string{txID},
})
if err != nil {
return 0, errors.Wrap(err, "query get rows")
}
logger.Debugf("QS GetState: got response in %v", time.Since(now))
if len(res.Statuses) == 0 {
logger.Errorf("QS GetState: no statuses for tx %s", txID)
return 0, errors.Errorf("QS GetState: no statuses for tx %s", txID)
}
return int32(res.Statuses[0].StatusWithHeight.Code), nil
}

func (s *RemoteQueryService) query(m map[driver.Namespace][]driver.PKey) (map[driver.Namespace]map[driver.PKey]driver.VaultValue, error) {
logger.Debugf("QS GetState: query input %v", m)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ import (

"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice/fakes"
queryservice2 "github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice/fakes"
"github.com/hyperledger/fabric-x-committer/api/protoqueryservice"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protowire"
)

func setupTest(tb testing.TB) (*queryservice.RemoteQueryService, *fakes.FakeQueryServiceClient) {
func setupTest(tb testing.TB) (*queryservice2.RemoteQueryService, *fakes.FakeQueryServiceClient) {
tb.Helper()

config := &queryservice.Config{
config := &queryservice2.Config{
Endpoints: nil,
QueryTimeout: 5 * time.Second,
}

client := &fakes.FakeQueryServiceClient{}
qs := queryservice.NewRemoteQueryService(config, client)
qs := queryservice2.NewRemoteQueryService(config, client)

return qs, client
}
Expand Down
2 changes: 1 addition & 1 deletion platform/fabricx/core/vault/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
fdriver "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/storage/vault"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/vault/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/queryservice"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/metrics"
"go.opentelemetry.io/otel/trace"
)
Expand Down
27 changes: 27 additions & 0 deletions platform/fabricx/driver/finality.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package driver

import (
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
fdriver "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/core/finality"
)

const (
Valid = fdriver.Valid
Invalid = fdriver.Invalid
Unknown = fdriver.Unknown
Busy = fdriver.Busy
)

type (
TxID = driver.TxID
FinalityListener = fabric.FinalityListener
FinalityListenerManager = finality.ListenerManager
)
25 changes: 25 additions & 0 deletions platform/fabricx/driver/qs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package driver

import (
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
fdriver "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
)

type (
ValidationCode = fdriver.ValidationCode
Namespace = driver.Namespace
PKey = driver.PKey
VaultValue = driver.VaultValue
)

type QueryService interface {
GetState(ns Namespace, key PKey) (*VaultValue, error)
GetStates(map[Namespace][]PKey) (map[Namespace]map[PKey]VaultValue, error)
GetTransactionStatus(txID string) (int32, error)
}
32 changes: 32 additions & 0 deletions platform/fabricx/finality.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package fabricx

import (
"github.com/hyperledger-labs/fabric-smart-client/platform/fabricx/driver"
)

type (
TxID = driver.TxID
FinalityListener = driver.FinalityListener
)

type Finality struct {
manager driver.FinalityListenerManager
}

func NewFinality(manager driver.FinalityListenerManager) *Finality {
return &Finality{manager: manager}
}

func (f *Finality) AddFinalityListener(txID TxID, listener FinalityListener) error {
return f.manager.AddFinalityListener(txID, listener)
}

func (f *Finality) RemoveFinalityListener(txID TxID, listener FinalityListener) error {
return f.manager.RemoveFinalityListener(txID, listener)
}
Loading
Loading