Skip to content

Commit

Permalink
Fleek/pass keys through newdb api (#1) (#460)
Browse files Browse the repository at this point in the history
* Pass thread key and log key through NewDB and NewDBFromAddr

* Handle null thread key

Signed-off-by: Daniel Merrill <danielmerrill6@gmail.com>
  • Loading branch information
dmerrill6 authored Nov 2, 2020
1 parent 43cf56e commit 8be7022
Show file tree
Hide file tree
Showing 5 changed files with 3,530 additions and 1,925 deletions.
21 changes: 21 additions & 0 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,22 @@ func (c *Client) NewDB(ctx context.Context, dbID thread.ID, opts ...db.NewManage
}
pbcollections[i] = cc
}
var logKey []byte
if args.LogKey != nil {
var err error
logKey, err = args.LogKey.Bytes()
if err != nil {
return err
}
}
ctx = thread.NewTokenContext(ctx, args.Token)
_, err := c.c.NewDB(ctx, &pb.NewDBRequest{
DbID: dbID.Bytes(),
Collections: pbcollections,
Name: args.Name,
Block: args.Block,
ThreadKey: args.ThreadKey.Bytes(),
LogKey: logKey,
})
return err
}
Expand All @@ -190,13 +201,23 @@ func (c *Client) NewDBFromAddr(ctx context.Context, dbAddr ma.Multiaddr, dbKey t
}
pbcollections[i] = cc
}
var logKey []byte
if args.LogKey != nil {
var err error
logKey, err = args.LogKey.Bytes()
if err != nil {
return err
}
}
ctx = thread.NewTokenContext(ctx, args.Token)
_, err := c.c.NewDBFromAddr(ctx, &pb.NewDBFromAddrRequest{
Addr: dbAddr.Bytes(),
Key: dbKey.Bytes(),
Collections: pbcollections,
Name: args.Name,
Block: args.Block,
ThreadKey: args.ThreadKey.Bytes(),
LogKey: logKey,
})
return err
}
Expand Down
Loading

0 comments on commit 8be7022

Please sign in to comment.