Skip to content

Commit

Permalink
Merge pull request #69 from DRK3/UpdateMongoDBWithFixedVersion
Browse files Browse the repository at this point in the history
feat: Update MongoDB storage provider with fixed version
  • Loading branch information
fqutishat authored Sep 10, 2021
2 parents b2afd0b + b7dcde7 commit 1e2cdf1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 553 deletions.
22 changes: 9 additions & 13 deletions cmd/vct/startcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func startAgent(parameters *agentParameters) error { // nolint: funlen
conns := map[string]*grpc.ClientConn{}

for i := range parameters.logs {
var treeID int64
var tree *trillian.Tree

conn, ok := conns[parameters.logs[i].Endpoint]
if !ok {
Expand All @@ -472,13 +472,13 @@ func startAgent(parameters *agentParameters) error { // nolint: funlen
conns[parameters.logs[i].Endpoint] = conn
}

treeID, err = createTreeAndInit(conn, configStore, parameters.logs[i].Alias,
tree, err = createTreeAndInit(conn, configStore, parameters.logs[i].Alias,
parameters.timeout, parameters.syncTimeout)
if err != nil {
return fmt.Errorf("create tree: %w", err)
}

parameters.logs[i].ID = treeID
parameters.logs[i].ID = tree.TreeId
parameters.logs[i].Client = trillian.NewTrillianLogClient(conn)
}

Expand Down Expand Up @@ -556,10 +556,10 @@ func (w *webVDR) Read(didID string, opts ...vdrapi.DIDMethodOption) (*did.DocRes
}

func createTreeAndInit(conn *grpc.ClientConn, cfg storage.Store, alias string, timeout,
syncTimeout uint64) (int64, error) {
var treeID int64
syncTimeout uint64) (*trillian.Tree, error) {
var tree *trillian.Tree

err := getOrInit(cfg, treeLogKey+"-"+alias, &treeID, func() (interface{}, error) {
err := getOrInit(cfg, treeLogKey+"-"+alias, &tree, func() (interface{}, error) {
var (
createdTree *trillian.Tree
err error
Expand Down Expand Up @@ -588,17 +588,13 @@ func createTreeAndInit(conn *grpc.ClientConn, cfg storage.Store, alias string, t
&trillian.InitLogRequest{LogId: createdTree.TreeId},
)

if err != nil {
return nil, err
}

return createdTree.TreeId, nil // nolint: wrapcheck
return createdTree, err // nolint: wrapcheck
}, syncTimeout)
if err != nil {
return -1, fmt.Errorf("create and init tree: %w", err)
return nil, fmt.Errorf("create and init tree: %w", err)
}

return treeID, nil
return tree, nil
}

func getOrInit(cfg storage.Store, key string, v interface{}, initFn func() (interface{}, error), timeout uint64) error {
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/hyperledger/aries-framework-go v0.1.7-0.20210816113201-26c0665ef2b9
github.com/hyperledger/aries-framework-go-ext/component/storage/couchdb v0.0.0-20210714131038-41b5bccef1f9
github.com/hyperledger/aries-framework-go-ext/component/storage/mongodb v0.0.0-20210826164831-40568174ea45
github.com/hyperledger/aries-framework-go-ext/component/storage/mysql v0.0.0-20210714131038-41b5bccef1f9
github.com/hyperledger/aries-framework-go-ext/component/storage/couchdb v0.0.0-20210909220549-ce3a2ee13e22
github.com/hyperledger/aries-framework-go-ext/component/storage/mongodb v0.0.0-20210909220549-ce3a2ee13e22
github.com/hyperledger/aries-framework-go-ext/component/storage/mysql v0.0.0-20210909220549-ce3a2ee13e22
github.com/hyperledger/aries-framework-go/component/storageutil v0.0.0-20210807121559-b41545a4f1e8
github.com/hyperledger/aries-framework-go/spi v0.0.0-20210820204349-ab3143ab760b
github.com/hyperledger/aries-framework-go/spi v0.0.0-20210909135806-a1c268dfb633
github.com/lib/pq v1.10.0
github.com/ory/dockertest/v3 v3.7.0
github.com/piprate/json-gold v0.4.1-0.20210813112359-33b90c4ca86c
Expand Down
Loading

0 comments on commit 1e2cdf1

Please sign in to comment.