Developing lightweight computation at the DSG edge

Commit 53cb92ef authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[goclidote] Commit transactions


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 6c30de93
......@@ -36,6 +36,9 @@ func AntidoteAddItemToSetInBucket(bucketName string, setName string, itemValue s
setVal, err := bucket.ReadSet(tx, key)
errCheck(err, "")
err = tx.Commit()
errCheck(err, "")
for _, v := range setVal {
if string(v) == itemValue {
return true
......@@ -61,7 +64,10 @@ func AntidoteReadRegisterInBucket(bucketName string, registerName string) string
setVal, err := bucket.ReadReg(tx, key)
errCheck(err, "")
return string(setVal)
err = tx.Commit()
errCheck(err, "")
return string(setVal[:])
}
// AntidoteSetRegisterInBucket set a LWWW register in a bucket
......@@ -83,7 +89,10 @@ func AntidoteSetRegisterInBucket(bucketName string, registerName string, itemVal
setVal, err := bucket.ReadReg(tx, key)
errCheck(err, "")
if string(setVal[0]) == itemValue {
err = tx.Commit()
errCheck(err, "")
if string(setVal[:]) == itemValue {
return true
}
......@@ -109,7 +118,10 @@ func AntidoteRemoveRegisterInBucket(bucketName string, registerName string) bool
setVal, err := bucket.ReadReg(tx, key)
errCheck(err, "")
if string(setVal[0]) == "" {
err = tx.Commit()
errCheck(err, "")
if string(setVal[:]) == "" {
return true
}
......@@ -134,6 +146,9 @@ func AntidoteReadItemsFromSetInBucket(bucketName string, setName string) []strin
setVal, err := bucket.ReadSet(tx, key)
errCheck(err, "")
err = tx.Commit()
errCheck(err, "")
for _, v := range setVal {
items = append(items, string(v))
}
......@@ -160,6 +175,9 @@ func AntidoteRemoveItemFromSetInBucket(bucketName string, setName string, itemVa
setVal, err := bucket.ReadSet(tx, key)
errCheck(err, "")
err = tx.Commit()
errCheck(err, "")
itemNotInSet := true
for _, v := range setVal {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment