Major integrations and fixes: - Added BACKBEAT SDK integration for P2P operation timing - Implemented beat-aware status tracking for distributed operations - Added Docker secrets support for secure license management - Resolved KACHING license validation via HTTPS/TLS - Updated docker-compose configuration for clean stack deployment - Disabled rollback policies to prevent deployment failures - Added license credential storage (CHORUS-DEV-MULTI-001) Technical improvements: - BACKBEAT P2P operation tracking with phase management - Enhanced configuration system with file-based secrets - Improved error handling for license validation - Clean separation of KACHING and CHORUS deployment stacks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package multihash
|
|
|
|
// Set is a set of Multihashes, holding one copy per Multihash.
|
|
type Set struct {
|
|
set map[string]struct{}
|
|
}
|
|
|
|
// NewSet creates a new set correctly initialized.
|
|
func NewSet() *Set {
|
|
return &Set{
|
|
set: make(map[string]struct{}),
|
|
}
|
|
}
|
|
|
|
// Add adds a new multihash to the set.
|
|
func (s *Set) Add(m Multihash) {
|
|
s.set[string(m)] = struct{}{}
|
|
}
|
|
|
|
// Len returns the number of elements in the set.
|
|
func (s *Set) Len() int {
|
|
return len(s.set)
|
|
}
|
|
|
|
// Has returns true if the element is in the set.
|
|
func (s *Set) Has(m Multihash) bool {
|
|
_, ok := s.set[string(m)]
|
|
return ok
|
|
}
|
|
|
|
// Visit adds a multihash only if it is not in the set already. Returns true
|
|
// if the multihash was added (was not in the set before).
|
|
func (s *Set) Visit(m Multihash) bool {
|
|
_, ok := s.set[string(m)]
|
|
if !ok {
|
|
s.set[string(m)] = struct{}{}
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ForEach runs f(m) with each multihash in the set. If returns immediately if
|
|
// f(m) returns an error.
|
|
func (s *Set) ForEach(f func(m Multihash) error) error {
|
|
for elem := range s.set {
|
|
mh := Multihash(elem)
|
|
if err := f(mh); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Remove removes an element from the set.
|
|
func (s *Set) Remove(m Multihash) {
|
|
delete(s.set, string(m))
|
|
}
|
|
|
|
// All returns a slice with all the elements in the set.
|
|
func (s *Set) All() []Multihash {
|
|
out := make([]Multihash, 0, len(s.set))
|
|
for m := range s.set {
|
|
out = append(out, Multihash(m))
|
|
}
|
|
return out
|
|
}
|