Skip to content

Enable SDK without use of SP #856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions integration/fsc/pingpong/cmd/initiator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong"
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong/mock"
fscnode "github.com/hyperledger-labs/fabric-smart-client/node"
"github.com/hyperledger-labs/fabric-smart-client/platform/view"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
viewsdk "github.com/hyperledger-labs/fabric-smart-client/platform/view/sdk/dig"
)

func main() {
node := fscnode.New()
node := fscnode.NewEmpty("")
utils.Must(node.InstallSDK(viewsdk.NewSDK(node)))
node.Execute(func() error {
registry := view.GetRegistry(node)
if err := registry.RegisterFactory("init", &pingpong.InitiatorViewFactory{}); err != nil {
if err := node.RegisterFactory("init", &pingpong.InitiatorViewFactory{}); err != nil {
return err
}
if err := registry.RegisterFactory("mockInit", &mock.InitiatorViewFactory{}); err != nil {
if err := node.RegisterFactory("mockInit", &mock.InitiatorViewFactory{}); err != nil {
return err
}
if err := registry.RegisterFactory("stream", &pingpong.StreamerViewFactory{}); err != nil {
if err := node.RegisterFactory("stream", &pingpong.StreamerViewFactory{}); err != nil {
return err
}
return nil
Expand Down
14 changes: 8 additions & 6 deletions integration/fsc/pingpong/cmd/responder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong"
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong/mock"
fscnode "github.com/hyperledger-labs/fabric-smart-client/node"
"github.com/hyperledger-labs/fabric-smart-client/platform/view"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
registry2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/core/registry"
viewsdk "github.com/hyperledger-labs/fabric-smart-client/platform/view/sdk/dig"
)

func main() {
node := fscnode.New()
node := fscnode.NewEmpty("")
utils.Must(node.InstallSDK(viewsdk.NewSDK(node)))
node.Execute(func() error {
registry := view.GetRegistry(node)
initiatorID := registry.GetIdentifier(&pingpong.Initiator{})
if err := registry.RegisterResponder(&pingpong.Responder{}, initiatorID); err != nil {
initiatorID := registry2.GetIdentifier(&pingpong.Initiator{})
if err := node.RegisterResponder(&pingpong.Responder{}, initiatorID); err != nil {
return err
}
if err := registry.RegisterResponder(&pingpong.Responder{}, &mock.Initiator{}); err != nil {
if err := node.RegisterResponder(&pingpong.Responder{}, &mock.Initiator{}); err != nil {
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion integration/fsc/pingpong/pingpong_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ var _ = Describe("EndToEnd", func() {
func newNode(conf string) api.FabricSmartClientNode {
n := node.NewEmpty(conf)
Expect(n).NotTo(BeNil())
n.AddSDK(viewsdk.NewSDK(n.Registry()))
n.AddSDK(viewsdk.NewSDK(n))
return n
}

Expand Down
60 changes: 30 additions & 30 deletions integration/fsc/stoprestart/stoprestart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ var _ = Describe("EndToEnd", func() {
It("stop and restart successfully", s.TestSucceeded)
})

Describe("Stop and Restart With Websockets", func() {
s := NewTestSuite(fsc.WebSocket, integration.NoReplication)
BeforeEach(s.Setup)
AfterEach(s.TearDown)
It("stop and restart successfully", s.TestSucceeded)
})

Describe("Stop and Restart with Fabric With Replicas many to one", func() {
s := NewTestSuite(fsc.WebSocket, &integration.ReplicationOptions{
ReplicationFactors: map[string]int{
"alice": 4,
"bob": 1,
},
})
BeforeEach(s.Setup)
AfterEach(s.TearDown)
It("stop and restart successfully", s.TestSucceededWithReplicas)
})

Describe("Stop and Restart with Fabric With Replicas many to many", func() {
s := NewTestSuite(fsc.WebSocket, &integration.ReplicationOptions{
ReplicationFactors: map[string]int{
"alice": 4,
"bob": 4,
},
})
BeforeEach(s.Setup)
AfterEach(s.TearDown)
It("stop and restart successfully", s.TestSucceededWithReplicas)
})
//Describe("Stop and Restart With Websockets", func() {
// s := NewTestSuite(fsc.WebSocket, integration.NoReplication)
// BeforeEach(s.Setup)
// AfterEach(s.TearDown)
// It("stop and restart successfully", s.TestSucceeded)
//})
//
//Describe("Stop and Restart with Fabric With Replicas many to one", func() {
// s := NewTestSuite(fsc.WebSocket, &integration.ReplicationOptions{
// ReplicationFactors: map[string]int{
// "alice": 4,
// "bob": 1,
// },
// })
// BeforeEach(s.Setup)
// AfterEach(s.TearDown)
// It("stop and restart successfully", s.TestSucceededWithReplicas)
//})
//
//Describe("Stop and Restart with Fabric With Replicas many to many", func() {
// s := NewTestSuite(fsc.WebSocket, &integration.ReplicationOptions{
// ReplicationFactors: map[string]int{
// "alice": 4,
// "bob": 4,
// },
// })
// BeforeEach(s.Setup)
// AfterEach(s.TearDown)
// It("stop and restart successfully", s.TestSucceededWithReplicas)
//})
})

type TestSuite struct {
Expand Down
7 changes: 2 additions & 5 deletions integration/nwo/fsc/node/node_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ package main

import (
fscnode "github.com/hyperledger-labs/fabric-smart-client/node"

{{ if InstallView }}viewregistry "github.com/hyperledger-labs/fabric-smart-client/platform/view"{{ end }}
{{- range .Imports }}
{{ Alias . }} "{{ . }}"{{ end }}
)
Expand All @@ -29,13 +27,12 @@ func main() {
{{ end }}
n.Execute(func() error {
{{- if InstallView }}
registry := viewregistry.GetRegistry(n)
{{- range .Factories }}
if err := registry.RegisterFactory("{{ .Id }}", {{ .Type }}); err != nil {
if err := n.RegisterFactory("{{ .Id }}", {{ .Type }}); err != nil {
return err
}{{ end }}
{{- range .Responders }}
registry.RegisterResponder({{ .Responder }}, {{ .Initiator }}){{ end }}
n.RegisterResponder({{ .Responder }}, {{ .Initiator }}){{ end }}
{{ end }}
return nil
})
Expand Down
12 changes: 8 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ type FabricSmartClient interface {
Start() error
Stop()
InstallSDK(p api.SDK) error
ConfigService() node3.ConfigService
Registry() node3.Registry
GetService(v interface{}) (interface{}, error)
RegisterService(service interface{}) error
ConfigService() node3.ConfigService
RegisterFactory(id string, factory api.Factory) error
RegisterResponder(responder view.View, initiatedBy interface{}) error
RegisterResponderWithIdentity(responder view.View, id view.Identity, initiatedBy view.View) error
ResolveIdentities(endpoints ...string) ([]view.Identity, error)

// RegisterViewManager injects the ViewManager dependency
RegisterViewManager(manager node3.ViewManager)

// RegisterViewRegistry injects the ViewRegistry dependency
RegisterViewRegistry(registry node3.ViewRegistry)
}

type node struct {
Expand All @@ -51,7 +55,7 @@ func New() *node {

func NewFromConfPath(confPath string) *node {
n := node3.NewEmpty(confPath)
n.AddSDK(sdk.NewSDK(n.Registry()))
n.AddSDK(sdk.NewSDK(n))
return newFromFsc(n)
}

Expand Down
7 changes: 1 addition & 6 deletions node/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"syscall"

"github.com/hyperledger-labs/fabric-smart-client/node/node/profile"
node3 "github.com/hyperledger-labs/fabric-smart-client/pkg/node"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -28,7 +27,6 @@ const (
type Node interface {
Start() error
Stop()
ConfigService() node3.ConfigService
Callback() chan<- error
}

Expand Down Expand Up @@ -152,10 +150,7 @@ func serve() error {

callback(nil)

cs := node.ConfigService()
logger.Infof("Started peer with ID=[%s]",
cs.GetString("fsc.id"),
)
logger.Infof("Started peer")
return <-serve
}

Expand Down
1 change: 0 additions & 1 deletion pkg/api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
package api

type FabricSmartClientNode interface {
ServiceProvider
ViewRegistry
ContextProvider
ViewClient
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/serviceprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ package api

type ServiceProvider interface {
GetService(v interface{}) (interface{}, error)

RegisterService(service interface{}) error
}
Loading
Loading