chore: expose atomic_operation

This commit is contained in:
Richard Ramos 2023-08-01 11:56:27 -04:00
parent 75151c168b
commit 0cefd63734
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
1 changed files with 11 additions and 0 deletions

View File

@ -470,3 +470,14 @@ func (r *RLN) SetMetadata(metadata []byte) error {
func (r *RLN) GetMetadata() ([]byte, error) { func (r *RLN) GetMetadata() ([]byte, error) {
return r.w.GetMetadata() return r.w.GetMetadata()
} }
// AtomicOperation can be used to insert and remove elements into the merkle tree
func (r *RLN) AtomicOperation(index MembershipIndex, idCommsToInsert []IDCommitment, indicesToRemove []MembershipIndex) error {
idCommBytes := serializeCommitments(idCommsToInsert)
indicesBytes := serializeIndices(indicesToRemove)
execSuccess := r.w.AtomicOperation(index, idCommBytes, indicesBytes)
if !execSuccess {
return errors.New("could not execute atomic_operation")
}
return nil
}