Commit 139f92f5 authored by Sietse Ringers's avatar Sietse Ringers Committed by Sietse Ringers
Browse files

refactor: rename DoStoreTransaction to Transaction

parent fdbae9b6
...@@ -254,7 +254,7 @@ func (client *Client) addCredential(cred *credential) (err error) { ...@@ -254,7 +254,7 @@ func (client *Client) addCredential(cred *credential) (err error) {
client.credentialsCache[id][counter] = cred client.credentialsCache[id][counter] = cred
} }
return client.storage.DoStoreTransaction(func(tx *transaction) error { return client.storage.Transaction(func(tx *transaction) error {
if err = client.storage.TxStoreSignature(tx, cred); err != nil { if err = client.storage.TxStoreSignature(tx, cred); err != nil {
return err return err
} }
...@@ -284,7 +284,7 @@ func (client *Client) remove(id irma.CredentialTypeIdentifier, index int, storeL ...@@ -284,7 +284,7 @@ func (client *Client) remove(id irma.CredentialTypeIdentifier, index int, storeL
removed := map[irma.CredentialTypeIdentifier][]irma.TranslatedString{} removed := map[irma.CredentialTypeIdentifier][]irma.TranslatedString{}
removed[id] = attrs.Strings() removed[id] = attrs.Strings()
err := client.storage.DoStoreTransaction(func(tx *transaction) error { err := client.storage.Transaction(func(tx *transaction) error {
if err := client.storage.TxDeleteSignature(tx, attrs); err != nil { if err := client.storage.TxDeleteSignature(tx, attrs); err != nil {
return err return err
} }
...@@ -349,7 +349,7 @@ func (client *Client) RemoveAllCredentials() error { ...@@ -349,7 +349,7 @@ func (client *Client) RemoveAllCredentials() error {
Removed: removed, Removed: removed,
} }
return client.storage.DoStoreTransaction(func(tx *transaction) error { return client.storage.Transaction(func(tx *transaction) error {
if err := client.storage.TxDeleteAllAttributes(tx); err != nil { if err := client.storage.TxDeleteAllAttributes(tx); err != nil {
return err return err
} }
......
...@@ -3,10 +3,11 @@ package irmaclient ...@@ -3,10 +3,11 @@ package irmaclient
import ( import (
"encoding/binary" "encoding/binary"
"encoding/json" "encoding/json"
"github.com/go-errors/errors"
"path/filepath" "path/filepath"
"time" "time"
"github.com/go-errors/errors"
"github.com/privacybydesign/gabi" "github.com/privacybydesign/gabi"
"github.com/privacybydesign/irmago" "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs" "github.com/privacybydesign/irmago/internal/fs"
...@@ -107,7 +108,7 @@ func (s *storage) load(bucketName string, key string, dest interface{}) (found b ...@@ -107,7 +108,7 @@ func (s *storage) load(bucketName string, key string, dest interface{}) (found b
return return
} }
func (s *storage) DoStoreTransaction(f func(*transaction) error) error { func (s *storage) Transaction(f func(*transaction) error) error {
return s.db.Update(func(tx *bbolt.Tx) error { return s.db.Update(func(tx *bbolt.Tx) error {
return f(&transaction{tx}) return f(&transaction{tx})
}) })
...@@ -135,7 +136,7 @@ func (s *storage) TxStoreCLSignature(tx *transaction, credHash string, sig *gabi ...@@ -135,7 +136,7 @@ func (s *storage) TxStoreCLSignature(tx *transaction, credHash string, sig *gabi
} }
func (s *storage) StoreSecretKey(sk *secretKey) error { func (s *storage) StoreSecretKey(sk *secretKey) error {
return s.DoStoreTransaction(func(tx *transaction) error { return s.Transaction(func(tx *transaction) error {
return s.TxStoreSecretKey(tx, sk) return s.TxStoreSecretKey(tx, sk)
}) })
} }
...@@ -145,7 +146,7 @@ func (s *storage) TxStoreSecretKey(tx *transaction, sk *secretKey) error { ...@@ -145,7 +146,7 @@ func (s *storage) TxStoreSecretKey(tx *transaction, sk *secretKey) error {
} }
func (s *storage) StoreAttributes(credTypeID irma.CredentialTypeIdentifier, attrlistlist []*irma.AttributeList) error { func (s *storage) StoreAttributes(credTypeID irma.CredentialTypeIdentifier, attrlistlist []*irma.AttributeList) error {
return s.DoStoreTransaction(func(tx *transaction) error { return s.Transaction(func(tx *transaction) error {
return s.TxStoreAttributes(tx, credTypeID, attrlistlist) return s.TxStoreAttributes(tx, credTypeID, attrlistlist)
}) })
} }
...@@ -165,7 +166,7 @@ func (s *storage) TxDeleteAllAttributes(tx *transaction) error { ...@@ -165,7 +166,7 @@ func (s *storage) TxDeleteAllAttributes(tx *transaction) error {
} }
func (s *storage) StoreKeyshareServers(keyshareServers map[irma.SchemeManagerIdentifier]*keyshareServer) error { func (s *storage) StoreKeyshareServers(keyshareServers map[irma.SchemeManagerIdentifier]*keyshareServer) error {
return s.DoStoreTransaction(func(tx *transaction) error { return s.Transaction(func(tx *transaction) error {
return s.TxStoreKeyshareServers(tx, keyshareServers) return s.TxStoreKeyshareServers(tx, keyshareServers)
}) })
} }
...@@ -203,7 +204,7 @@ func (s *storage) logEntryKeyToBytes(id uint64) []byte { ...@@ -203,7 +204,7 @@ func (s *storage) logEntryKeyToBytes(id uint64) []byte {
} }
func (s *storage) StorePreferences(prefs Preferences) error { func (s *storage) StorePreferences(prefs Preferences) error {
return s.DoStoreTransaction(func(tx *transaction) error { return s.Transaction(func(tx *transaction) error {
return s.TxStorePreferences(tx, prefs) return s.TxStorePreferences(tx, prefs)
}) })
} }
...@@ -213,7 +214,7 @@ func (s *storage) TxStorePreferences(tx *transaction, prefs Preferences) error { ...@@ -213,7 +214,7 @@ func (s *storage) TxStorePreferences(tx *transaction, prefs Preferences) error {
} }
func (s *storage) StoreUpdates(updates []update) (err error) { func (s *storage) StoreUpdates(updates []update) (err error) {
return s.DoStoreTransaction(func(tx *transaction) error { return s.Transaction(func(tx *transaction) error {
return s.TxStoreUpdates(tx, updates) return s.TxStoreUpdates(tx, updates)
}) })
} }
......
...@@ -2,9 +2,10 @@ package irmaclient ...@@ -2,9 +2,10 @@ package irmaclient
import ( import (
"encoding/json" "encoding/json"
"github.com/privacybydesign/gabi"
"time" "time"
"github.com/privacybydesign/gabi"
"github.com/privacybydesign/irmago" "github.com/privacybydesign/irmago"
) )
...@@ -50,7 +51,7 @@ var clientUpdates = []func(client *Client) error{ ...@@ -50,7 +51,7 @@ var clientUpdates = []func(client *Client) error{
} }
// Open one bolt transaction to process all our log entries in // Open one bolt transaction to process all our log entries in
err = client.storage.DoStoreTransaction(func(tx *transaction) error { err = client.storage.Transaction(func(tx *transaction) error {
for _, log := range logs { for _, log := range logs {
// As log.Request is a json.RawMessage it would not get updated to the new session request // As log.Request is a json.RawMessage it would not get updated to the new session request
// format by re-marshaling the containing struct, as normal struct members would, // format by re-marshaling the containing struct, as normal struct members would,
...@@ -119,7 +120,7 @@ var clientUpdates = []func(client *Client) error{ ...@@ -119,7 +120,7 @@ var clientUpdates = []func(client *Client) error{
return err return err
} }
return client.storage.DoStoreTransaction(func(tx *transaction) error { return client.storage.Transaction(func(tx *transaction) error {
if err = client.storage.TxStoreSecretKey(tx, sk); err != nil { if err = client.storage.TxStoreSecretKey(tx, sk); err != nil {
return err return err
} }
......
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