Client badger WIP
This commit is contained in:
1 parent
998e00d245
commit
bc9f0c19b7
17 files changed
+1008
-30
No files matched your search
@@ -26,14 +26,12 @@ func (a aclKeys) RawRecordKey(id string) []byte {
|
||||
type treeKeys struct {
|
||||
id string
|
||||
headsKey []byte
|
||||
rootKey []byte
|
||||
}
|
||||
|
||||
func newTreeKeys(id string) treeKeys {
|
||||
return treeKeys{
|
||||
id: id,
|
||||
headsKey: joinStringsToBytes("t", id, "heads"),
|
||||
rootKey: joinStringsToBytes("t", id, "rootId"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +39,6 @@ func (t treeKeys) HeadsKey() []byte {
|
||||
return t.headsKey
|
||||
}
|
||||
|
||||
func (t treeKeys) RootIdKey() []byte {
|
||||
return t.rootKey
|
||||
}
|
||||
|
||||
func (t treeKeys) RawChangeKey(id string) []byte {
|
||||
return joinStringsToBytes("t", t.id, id)
|
||||
}
|
||||
|
||||
@@ -16,15 +16,6 @@ type listStorage struct {
|
||||
|
||||
func newListStorage(db *pogreb.DB) (ls storage.ListStorage, err error) {
|
||||
keys := aclKeys{}
|
||||
head, err := db.Get(keys.HeadIdKey())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if head == nil {
|
||||
err = storage.ErrUnknownACLId
|
||||
return
|
||||
}
|
||||
|
||||
rootId, err := db.Get(keys.RootIdKey())
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -18,15 +18,6 @@ type treeStorage struct {
|
||||
|
||||
func newTreeStorage(db *pogreb.DB, treeId string) (ts storage.TreeStorage, err error) {
|
||||
keys := newTreeKeys(treeId)
|
||||
has, err := db.Has(keys.RootIdKey())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !has {
|
||||
err = storage.ErrUnknownTreeId
|
||||
return
|
||||
}
|
||||
|
||||
heads, err := db.Get(keys.HeadsKey())
|
||||
if err != nil {
|
||||
return
|
||||
@@ -64,7 +55,7 @@ func newTreeStorage(db *pogreb.DB, treeId string) (ts storage.TreeStorage, err e
|
||||
|
||||
func createTreeStorage(db *pogreb.DB, payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) {
|
||||
keys := newTreeKeys(payload.TreeId)
|
||||
has, err := db.Has(keys.RootIdKey())
|
||||
has, err := db.Has(keys.HeadsKey())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -92,11 +83,6 @@ func createTreeStorage(db *pogreb.DB, payload storage.TreeStorageCreatePayload)
|
||||
return
|
||||
}
|
||||
|
||||
err = db.Put(keys.RootIdKey(), []byte(payload.RootRawChange.Id))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ts = &treeStorage{
|
||||
db: db,
|
||||
keys: keys,
|
||||
|
||||
Reference in new issue
Block a user