aboutsummaryrefslogtreecommitdiff
path: root/types/namespace.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-02-23 11:59:46 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-02-23 11:59:46 +0100
commitb4dd74a3f36ca46b7bcda69e8d95949babfeb76d (patch)
tree6f3cbe32be4e675ba385e2575e28cf7a0f4dca00 /types/namespace.go
parent1505c6db8e0e66d88a645ac5cc36647a6f8b2f43 (diff)
renamed and reordered to improve readability
Diffstat (limited to 'types/namespace.go')
-rw-r--r--types/namespace.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/types/namespace.go b/types/namespace.go
index f221960..3c6b90a 100644
--- a/types/namespace.go
+++ b/types/namespace.go
@@ -89,59 +89,3 @@ func (ns *Namespace) Verify(message, signature []byte) error {
}
return nil
}
-
-// NamespacePool is a pool of namespaces that contain complete verification keys
-type NamespacePool struct {
- pool map[string]*Namespace
- list []*Namespace
- // If we need to update this structure without a restart => add mutex.
-}
-
-// NewNameSpacePool creates a new namespace pool from a list of namespaces. An
-// error is returned if there are duplicate namespaces or namespaces without a
-// complete verification key. The latter is determined by namespaceWithKey().
-func NewNamespacePool(namespaces []*Namespace) (*NamespacePool, error) {
- np := &NamespacePool{
- pool: make(map[string]*Namespace),
- list: make([]*Namespace, 0),
- }
- for _, namespace := range namespaces {
- if !namespaceWithKey(namespace.Format) {
- return nil, fmt.Errorf("need verification key in namespace pool: %v", namespace.Format)
- }
- if _, ok := np.pool[namespace.String()]; ok {
- return nil, fmt.Errorf("duplicate namespace: %v", namespace.String())
- }
- np.pool[namespace.String()] = namespace
- np.list = append(np.list, namespace)
- }
- return np, nil
-}
-
-// Find checks if namespace is a member of the namespace pool.
-func (np *NamespacePool) Find(namespace *Namespace) (*Namespace, bool) {
- if _, ok := np.pool[namespace.String()]; !ok {
- return nil, false
- }
- // If the passed namespace is a key fingerprint the actual key needs to be
- // attached before returning. Not applicable for Ed25519. Docdoc later.
- return namespace, true
-}
-
-// List returns a copied list of namespaces that is used by this pool.
-func (np *NamespacePool) List() []*Namespace {
- namespaces := make([]*Namespace, len(np.list))
- copy(namespaces, np.list)
- return namespaces
-}
-
-// namespaceWithKey returns true if a namespace format contains a complete
-// verification key. I.e., some formats might have a key fingerprint instead.
-func namespaceWithKey(format NamespaceFormat) bool {
- switch format {
- case NamespaceFormatEd25519V1:
- return true
- default:
- return false
- }
-}