Skip to content

Commit

Permalink
Removed persistence implementations
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandros Filios <[email protected]>
  • Loading branch information
alexandrosfilios committed Feb 4, 2025
1 parent da5d4d1 commit 9a925ca
Show file tree
Hide file tree
Showing 59 changed files with 851 additions and 2,252 deletions.
12 changes: 6 additions & 6 deletions docs/fabric/fabricdev/core/fabricdev/vault/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import (

type CounterBasedVersionBuilder struct{}

func (c *CounterBasedVersionBuilder) VersionedValues(rws *vault.ReadWriteSet, ns driver.Namespace, writes vault.NamespaceWrites, block driver.BlockNum, indexInBloc driver.TxNum) (map[driver.PKey]vault.VersionedValue, error) {
vals := make(map[driver.PKey]vault.VersionedValue, len(writes))
func (c *CounterBasedVersionBuilder) VersionedValues(rws *vault.ReadWriteSet, ns driver.Namespace, writes vault.NamespaceWrites, block driver.BlockNum, indexInBloc driver.TxNum) (map[driver.PKey]driver.VaultValue, error) {
vals := make(map[driver.PKey]driver.VaultValue, len(writes))
reads := rws.Reads[ns]

for pkey, val := range writes {
v, err := version(reads, pkey)
if err != nil {
return nil, err
}
vals[pkey] = vault.VersionedValue{Raw: val, Version: v}
vals[pkey] = driver.VaultValue{Raw: val, Version: v}
}
return vals, nil
}
Expand All @@ -48,8 +48,8 @@ func version(reads vault.NamespaceReads, pkey driver.PKey) (vault.Version, error
return Marshal(counter + 1), nil
}

func (c *CounterBasedVersionBuilder) VersionedMetaValues(rws *vault.ReadWriteSet, ns driver.Namespace, writes vault.KeyedMetaWrites, block driver.BlockNum, indexInBloc driver.TxNum) (map[driver.PKey]driver.VersionedMetadataValue, error) {
vals := make(map[driver.PKey]driver.VersionedMetadataValue, len(writes))
func (c *CounterBasedVersionBuilder) VersionedMetaValues(rws *vault.ReadWriteSet, ns driver.Namespace, writes vault.KeyedMetaWrites, block driver.BlockNum, indexInBloc driver.TxNum) (map[driver.PKey]driver.VaultMetadataValue, error) {
vals := make(map[driver.PKey]driver.VaultMetadataValue, len(writes))
reads := rws.Reads[ns]

for pkey, val := range writes {
Expand All @@ -58,7 +58,7 @@ func (c *CounterBasedVersionBuilder) VersionedMetaValues(rws *vault.ReadWriteSet
return nil, err
}

vals[pkey] = driver.VersionedMetadataValue{Metadata: val, Version: v}
vals[pkey] = driver.VaultMetadataValue{Metadata: val, Version: v}
}
return vals, nil
}
Expand Down
8 changes: 4 additions & 4 deletions integration/fabric/iou/views/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ import (

"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"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"
)

var logger = logging.MustGetLogger("fabric.iou")

type FinalityListener struct {
ExpectedTxID string
ExpectedVC fabric.ValidationCode
ExpectedVC fdriver.ValidationCode
WaitGroup *sync.WaitGroup
}

func NewFinalityListener(expectedTxID string, expectedVC fabric.ValidationCode, waitGroup *sync.WaitGroup) *FinalityListener {
func NewFinalityListener(expectedTxID string, expectedVC fdriver.ValidationCode, waitGroup *sync.WaitGroup) *FinalityListener {
return &FinalityListener{ExpectedTxID: expectedTxID, ExpectedVC: expectedVC, WaitGroup: waitGroup}
}

func (t *FinalityListener) OnStatus(_ context.Context, txID driver.TxID, vc fabric.ValidationCode, _ string) {
func (t *FinalityListener) OnStatus(_ context.Context, txID driver.TxID, vc fdriver.ValidationCode, _ string) {
logger.Infof("on status [%s][%d]", txID, vc)
if txID == t.ExpectedTxID && vc == t.ExpectedVC {
time.Sleep(5 * time.Second)
Expand Down
10 changes: 7 additions & 3 deletions integration/nwo/fabric/network/network_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,12 @@ func (n *Network) nextColor() string {
return fmt.Sprintf("%dm", color)
}

func (n *Network) FSCNodeVaultDir(uniqueName string) string {
return filepath.Join(n.Context.RootDir(), "fsc", "nodes", uniqueName, n.Prefix, "vault")
func (n *Network) FSCNodeStorages(uniqueName string) string {
return filepath.Join(n.Context.RootDir(), "fsc", "nodes", uniqueName, n.Prefix)
}

func (n *Network) FSCNodeStorageDir(uniqueName string, suffix string) string {
return filepath.Join(n.FSCNodeStorages(uniqueName), suffix)
}

func (n *Network) OrdererBootstrapFile() string {
Expand Down Expand Up @@ -1615,7 +1619,7 @@ func (n *Network) GenerateCoreConfig(p *topology.Peer) {
"PeerAddress": func(o *topology.Peer, portName api.PortName) string { return n.PeerAddress(o, portName) },
"CACertsBundlePath": func() string { return n.CACertsBundlePath() },
"VaultOpts": func() node.PersistenceOpts {
return fsc.PersistenceOpts(VaultPersistencePrefix, p.FSCNode.Options)
return fsc.PersistenceOpts(VaultPersistencePrefix, p.FSCNode.Options, n.FSCNodeStorageDir(uniqueName, "vault"))
},
"FabricName": func() string { return n.topology.Name() },
"DefaultNetwork": func() bool { return defaultNetwork },
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/fabric/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (p *Platform) DeleteVault(id string) {
fscPeer := p.Network.FSCPeerByName(id)
Expect(fscPeer).ToNot(BeNil())
for _, uniqueName := range fscPeer.FSCNode.ReplicaUniqueNames() {
Expect(os.RemoveAll(p.Network.FSCNodeVaultDir(uniqueName))).ToNot(HaveOccurred())
Expect(os.RemoveAll(p.Network.FSCNodeStorageDir(uniqueName, "vault"))).ToNot(HaveOccurred())
}
}

Expand Down
31 changes: 20 additions & 11 deletions integration/nwo/fsc/fsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
view2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/view/cmd"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/web"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/crypto"
mem "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/memory"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/sql"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/sql/postgres"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc"
Expand Down Expand Up @@ -519,25 +518,25 @@ func (p *Platform) GenerateCoreConfig(peer *node2.Replica) {
"ToLower": func(s string) string { return strings.ToLower(s) },
"ReplaceAll": func(s, old, new string) string { return strings.Replace(s, old, new, -1) },
"KVSOpts": func() node2.PersistenceOpts {
return PersistenceOpts(KvsPersistencePrefix, peer.Options)
return PersistenceOpts(KvsPersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "kvs"))
},
"BindingOpts": func() node2.PersistenceOpts {
return PersistenceOpts(BindingPersistencePrefix, peer.Options)
return PersistenceOpts(BindingPersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "bind"))
},
"SignerInfoOpts": func() node2.PersistenceOpts {
return PersistenceOpts(SignerInfoPersistencePrefix, peer.Options)
return PersistenceOpts(SignerInfoPersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "sig"))
},
"AuditInfoOpts": func() node2.PersistenceOpts {
return PersistenceOpts(AuditInfoPersistencePrefix, peer.Options)
return PersistenceOpts(AuditInfoPersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "aud"))
},
"EndorseTxOpts": func() node2.PersistenceOpts {
return PersistenceOpts(EndorseTxPersistencePrefix, peer.Options)
return PersistenceOpts(EndorseTxPersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "etx"))
},
"EnvelopeOpts": func() node2.PersistenceOpts {
return PersistenceOpts(EnvelopePersistencePrefix, peer.Options)
return PersistenceOpts(EnvelopePersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "env"))
},
"MetadataOpts": func() node2.PersistenceOpts {
return PersistenceOpts(MetadataPersistencePrefix, peer.Options)
return PersistenceOpts(MetadataPersistencePrefix, peer.Options, p.NodeStorageDir(peer.UniqueName, "mtd"))
},
"Resolvers": func() []*Resolver { return resolvers },
"WebEnabled": func() bool { return p.Topology.WebEnabled },
Expand All @@ -552,14 +551,20 @@ func (p *Platform) GenerateCoreConfig(peer *node2.Replica) {

}

func PersistenceOpts(prefix string, o *node2.Options) node2.PersistenceOpts {
func PersistenceOpts(prefix string, o *node2.Options, dir string) node2.PersistenceOpts {
if sqlOpts := o.GetPersistence(prefix); sqlOpts != nil {
return node2.PersistenceOpts{
Type: sql.SQLPersistence,
SQL: sqlOpts,
}
}
return node2.PersistenceOpts{Type: mem.MemoryPersistence}
return node2.PersistenceOpts{
Type: sql.SQLPersistence,
SQL: &node2.SQLOpts{
DriverType: sql.SQLite,
DataSource: fmt.Sprintf("%s.sqlite", dir),
CreateSchema: true,
}}
}

func (p *Platform) BootstrapViewNodeGroupRunner() ifrit.Runner {
Expand Down Expand Up @@ -668,8 +673,12 @@ func (p *Platform) NodeClientConfigPath(peer *node2.Replica) string {
return filepath.Join(p.Context.RootDir(), "fsc", "nodes", peer.UniqueName, "client-config.yaml")
}

func (p *Platform) NodeStorages(uniqueName string) string {
return filepath.Join(p.Context.RootDir(), "fsc", "nodes", uniqueName)
}

func (p *Platform) NodeStorageDir(uniqueName string, dirName string) string {
return filepath.Join(p.Context.RootDir(), "fsc", "nodes", uniqueName, dirName)
return filepath.Join(p.NodeStorages(uniqueName), dirName)
}

func (p *Platform) NodeConfigPath(peer *node2.Replica) string {
Expand Down
Loading

0 comments on commit 9a925ca

Please sign in to comment.