mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-04-28 03:00:41 -04:00
Merge pull request #95 from appliedzkp/refactor/root-history
refactor: remove root history mapping
Former-commit-id: 555b397634
This commit is contained in:
@@ -8,18 +8,13 @@ import "@openzeppelin/contracts/utils/Context.sol";
|
||||
|
||||
/// @title Semaphore groups contract.
|
||||
/// @dev The following code allows you to create groups, add and remove members.
|
||||
/// You can use getters to obtain informations about groups, whereas the `rootHistory`
|
||||
/// mapping can be used to check if a Semaphore proof root exists onchain.
|
||||
/// You can use getters to obtain informations about groups (root, depth, number of leaves).
|
||||
abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
|
||||
using IncrementalBinaryTree for IncrementalTreeData;
|
||||
|
||||
/// @dev Gets a group id and returns the group/tree data.
|
||||
mapping(uint256 => IncrementalTreeData) internal groups;
|
||||
|
||||
/// @dev Gets a root hash and returns the group id.
|
||||
/// It can be used to check if the root a Semaphore proof exists.
|
||||
mapping(uint256 => uint256) internal rootHistory;
|
||||
|
||||
/// @dev Creates a new group by initializing the associated tree.
|
||||
/// @param groupId: Id of the group.
|
||||
/// @param depth: Depth of the tree.
|
||||
@@ -46,7 +41,6 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
|
||||
groups[groupId].insert(identityCommitment);
|
||||
|
||||
uint256 root = getRoot(groupId);
|
||||
rootHistory[root] = groupId;
|
||||
|
||||
emit MemberAdded(groupId, identityCommitment, root);
|
||||
}
|
||||
@@ -68,9 +62,8 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
|
||||
groups[groupId].remove(identityCommitment, proofSiblings, proofPathIndices);
|
||||
|
||||
uint256 root = getRoot(groupId);
|
||||
rootHistory[root] = groupId;
|
||||
|
||||
emit MemberRemoved(groupId, identityCommitment, groups[groupId].root);
|
||||
emit MemberRemoved(groupId, identityCommitment, root);
|
||||
}
|
||||
|
||||
/// @dev See {ISemaphoreGroups-getRoot}.
|
||||
|
||||
Reference in New Issue
Block a user