@@ -29,13 +29,13 @@ import (
2929 "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/commands"
3030 node2 "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/node"
3131 "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring/optl"
32- driver2 "github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
3332 "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
3433 tracing2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/sdk/tracing"
3534 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/view"
3635 view2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/view/cmd"
3736 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/web"
3837 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/crypto"
38+ "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/badger"
3939 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/sql"
4040 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc"
4141 "github.com/miracl/conflate"
@@ -483,17 +483,36 @@ func (p *Platform) GenerateCoreConfig(peer *node2.Replica) {
483483 }
484484
485485 t , err := template .New ("peer" ).Funcs (template.FuncMap {
486- "Replica" : func () * node2.Replica { return peer },
487- "Peer" : func () * node2.Peer { return peer .Peer },
488- "NetworkID" : func () string { return p .NetworkID },
489- "Topology" : func () * Topology { return p .Topology },
490- "Extensions" : func () []string { return extensions },
491- "ToLower" : func (s string ) string { return strings .ToLower (s ) },
492- "ReplaceAll" : func (s , old , new string ) string { return strings .Replace (s , old , new , - 1 ) },
493- "NodeKVSPath" : func () string { return p .NodeKVSDir (peer ) },
494- "NodeKVSPersistence" : func () node2.PersistenceOpts { return peer .Options .GetPersistence ("fsc" ) },
495- "Resolvers" : func () []* Resolver { return resolvers },
496- "WebEnabled" : func () bool { return p .Topology .WebEnabled },
486+ "Replica" : func () * node2.Replica { return peer },
487+ "Peer" : func () * node2.Peer { return peer .Peer },
488+ "NetworkID" : func () string { return p .NetworkID },
489+ "Topology" : func () * Topology { return p .Topology },
490+ "Extensions" : func () []string { return extensions },
491+ "ToLower" : func (s string ) string { return strings .ToLower (s ) },
492+ "ReplaceAll" : func (s , old , new string ) string { return strings .Replace (s , old , new , - 1 ) },
493+ "KVSOpts" : func () node2.PersistenceOpts {
494+ return p .PersistenceOpts (KvsPersistencePrefix , peer .UniqueName , peer .Options , "kvs" )
495+ },
496+ "BindingOpts" : func () node2.PersistenceOpts {
497+ return p .PersistenceOpts (BindingPersistencePrefix , peer .UniqueName , peer .Options , "binding" )
498+ },
499+ "SignerInfoOpts" : func () node2.PersistenceOpts {
500+ return p .PersistenceOpts (SignerInfoPersistencePrefix , peer .UniqueName , peer .Options , "signer" )
501+ },
502+ "AuditInfoOpts" : func () node2.PersistenceOpts {
503+ return p .PersistenceOpts (AuditInfoPersistencePrefix , peer .UniqueName , peer .Options , "audit" )
504+ },
505+ "EndorseTxOpts" : func () node2.PersistenceOpts {
506+ return p .PersistenceOpts (EndorseTxPersistencePrefix , peer .UniqueName , peer .Options , "etx" )
507+ },
508+ "EnvelopeOpts" : func () node2.PersistenceOpts {
509+ return p .PersistenceOpts (EnvelopePersistencePrefix , peer .UniqueName , peer .Options , "env" )
510+ },
511+ "MetadataOpts" : func () node2.PersistenceOpts {
512+ return p .PersistenceOpts (MetadataPersistencePrefix , peer .UniqueName , peer .Options , "metadata" )
513+ },
514+ "Resolvers" : func () []* Resolver { return resolvers },
515+ "WebEnabled" : func () bool { return p .Topology .WebEnabled },
497516 "TracingEndpoint" : func () string {
498517 return utils .DefaultString (p .Topology .Monitoring .TracingEndpoint , fmt .Sprintf ("0.0.0.0:%d" , optl .JaegerCollectorPort ))
499518 },
@@ -502,6 +521,21 @@ func (p *Platform) GenerateCoreConfig(peer *node2.Replica) {
502521 Parse (p .Topology .Templates .CoreTemplate ())
503522 Expect (err ).NotTo (HaveOccurred ())
504523 Expect (t .Execute (io .MultiWriter (core ), p )).NotTo (HaveOccurred ())
524+
525+ }
526+
527+ func (p * Platform ) PersistenceOpts (prefix string , uniqueName string , o * node2.Options , dirName string ) node2.PersistenceOpts {
528+ if sqlOpts := o .GetPersistence (prefix ); sqlOpts != nil {
529+ return node2.PersistenceOpts {
530+ Type : sql .SQLPersistence ,
531+ SQL : sqlOpts ,
532+ }
533+ } else {
534+ return node2.PersistenceOpts {
535+ Type : badger .BadgerPersistence ,
536+ Badger : & node2.BadgerOpts {Path : p .NodeStorageDir (uniqueName , dirName )},
537+ }
538+ }
505539}
506540
507541func (p * Platform ) BootstrapViewNodeGroupRunner () ifrit.Runner {
@@ -589,9 +623,8 @@ func (p *Platform) GenerateCmd(output io.Writer, node *node2.Replica) string {
589623 }
590624
591625 t , err := template .New ("node" ).Funcs (template.FuncMap {
592- "Alias" : func (s string ) string { return node .Node .Alias (s ) },
593- "InstallView" : func () bool { return len (node .Node .Responders ) != 0 || len (node .Node .Factories ) != 0 },
594- "InstallPostgres" : func () bool { return GetPersistenceType (node .Peer ) == sql .SQLPersistence },
626+ "Alias" : func (s string ) string { return node .Node .Alias (s ) },
627+ "InstallView" : func () bool { return len (node .Node .Responders ) != 0 || len (node .Node .Factories ) != 0 },
595628 }).Parse (p .Topology .Templates .NodeTemplate ())
596629 Expect (err ).NotTo (HaveOccurred ())
597630
@@ -611,8 +644,8 @@ func (p *Platform) NodeClientConfigPath(peer *node2.Replica) string {
611644 return filepath .Join (p .Context .RootDir (), "fsc" , "nodes" , peer .UniqueName , "client-config.yaml" )
612645}
613646
614- func (p * Platform ) NodeKVSDir ( peer * node2. Replica ) string {
615- return filepath .Join (p .Context .RootDir (), "fsc" , "nodes" , peer . UniqueName , "kvs" )
647+ func (p * Platform ) NodeStorageDir ( uniqueName string , dirName string ) string {
648+ return filepath .Join (p .Context .RootDir (), "fsc" , "nodes" , uniqueName , dirName )
616649}
617650
618651func (p * Platform ) NodeConfigPath (peer * node2.Replica ) string {
@@ -873,14 +906,6 @@ func (p *Platform) nextColor() string {
873906 return fmt .Sprintf ("%dm" , color )
874907}
875908
876- func GetPersistenceType (peer * node2.Peer ) driver2.PersistenceType {
877- return peer .Options .GetPersistence ("fsc" ).Type
878- }
879-
880- func GetPersistenceDataSource (peer * node2.Peer ) string {
881- return peer .Options .GetPersistence ("fsc" ).SQL .DataSource
882- }
883-
884909// PeerPortNames returns the list of ports that need to be reserved for a Peer.
885910func PeerPortNames () []api.PortName {
886911 return []api.PortName {ListenPort , P2PPort , WebPort }
0 commit comments