Commit 1acbda2b authored by Ivar Derksen's avatar Ivar Derksen Committed by Sietse Ringers

Not always store all credential when only one changes

parent d633e203
......@@ -246,7 +246,7 @@ func (client *Client) addCredential(cred *credential, storeAttributes bool) (err
return
}
if storeAttributes {
err = client.storage.StoreAttributes(client.attributes)
err = client.storage.StoreAttribute(id, client.attributes[id])
}
return
}
......@@ -270,7 +270,7 @@ func (client *Client) remove(id irma.CredentialTypeIdentifier, index int, storen
attrs := list[index]
client.attributes[id] = append(list[:index], list[index+1:]...)
if storenow {
if err := client.storage.StoreAttributes(client.attributes); err != nil {
if err := client.storage.StoreAttribute(id, client.attributes[id]); err != nil {
return err
}
}
......
......@@ -175,6 +175,18 @@ func (s *storage) TxStoreSecretKey(tx *bbolt.Tx, sk *secretKey) error {
return s.txStore(tx, skKey, sk, userdataBucket)
}
func (s *storage) StoreAttribute(credTypeID irma.CredentialTypeIdentifier, attrlistlist []*irma.AttributeList) error {
return s.db.Update(func(tx *bbolt.Tx) error {
return s.TxStoreAttribute(tx, credTypeID, attrlistlist)
})
}
func (s *storage) TxStoreAttribute(tx *bbolt.Tx, credTypeID irma.CredentialTypeIdentifier,
attrlistlist []*irma.AttributeList) error {
return s.txStore(tx, credTypeID.String(), attrlistlist, attributesBucket)
}
func (s *storage) StoreAttributes(attributes map[irma.CredentialTypeIdentifier][]*irma.AttributeList) error {
return s.db.Update(func(tx *bbolt.Tx) error {
return s.TxStoreAttributes(tx, attributes)
......@@ -183,7 +195,7 @@ func (s *storage) StoreAttributes(attributes map[irma.CredentialTypeIdentifier][
func (s *storage) TxStoreAttributes(tx *bbolt.Tx, attrs map[irma.CredentialTypeIdentifier][]*irma.AttributeList) error {
for credTypeID, attrlistlist := range attrs {
err := s.txStore(tx, credTypeID.String(), attrlistlist, attributesBucket)
err := s.TxStoreAttribute(tx, credTypeID, attrlistlist)
if err != nil {
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