-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flatten ads package to avoid exporting concrete types
- Loading branch information
Showing
6 changed files
with
57 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ads | ||
|
||
import ( | ||
"github.com/iotaledger/hive.go/ds/types" | ||
"github.com/iotaledger/hive.go/kvstore" | ||
) | ||
|
||
// Set is a sparse merkle tree based set. | ||
type authenticatedSet[K any] struct { | ||
*authenticatedMap[K, types.Empty] | ||
} | ||
|
||
// NewAuthenticatedSet creates a new sparse merkle tree based set. | ||
func newAuthenticatedSet[K any](store kvstore.KVStore, kToBytes kvstore.ObjectToBytes[K], bytesToK kvstore.BytesToObject[K]) *authenticatedSet[K] { | ||
return &authenticatedSet[K]{ | ||
authenticatedMap: newAuthenticatedMap(store, kToBytes, bytesToK, types.Empty.Bytes, types.EmptyFromBytes), | ||
} | ||
} | ||
|
||
// Add adds the key to the set. | ||
func (s *authenticatedSet[K]) Add(key K) error { | ||
return s.Set(key, types.Void) | ||
} | ||
|
||
// Stream iterates over the set and calls the callback for each element. | ||
func (s *authenticatedSet[K]) Stream(callback func(key K) error) error { | ||
return s.authenticatedMap.Stream(func(key K, _ types.Empty) error { | ||
return callback(key) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters