@@ -6,54 +6,54 @@ import (
6
6
7
7
// ContractMetadataStore is an interface that represents an immutable view over a set
8
8
// of ContractMetadata records identified by ContractMetadataKey.
9
- type ContractMetadataStore [ M any ] interface {
10
- Store [ContractMetadataKey , ContractMetadata [ M ] ]
9
+ type ContractMetadataStore interface {
10
+ Store [ContractMetadataKey , ContractMetadata ]
11
11
}
12
12
13
13
// MutableContractMetadataStore is an interface that represents a mutable ContractMetadataStore
14
14
// of ContractMetadata records identified by ContractMetadataKey.
15
- type MutableContractMetadataStore [ M any ] interface {
16
- MutableStore [ContractMetadataKey , ContractMetadata [ M ] ]
15
+ type MutableContractMetadataStore interface {
16
+ MutableStore [ContractMetadataKey , ContractMetadata ]
17
17
}
18
18
19
19
// MemoryContractMetadataStore is an in-memory implementation of the ContractMetadataStore and
20
20
// MutableContractMetadataStore interfaces.
21
- type MemoryContractMetadataStore [ M any ] struct {
21
+ type MemoryContractMetadataStore struct {
22
22
mu sync.RWMutex
23
- Records []ContractMetadata [ M ] `json:"records"`
23
+ Records []ContractMetadata `json:"records"`
24
24
}
25
25
26
26
// MemoryContractMetadataStore implements ContractMetadataStore interface.
27
- var _ ContractMetadataStore [ DefaultMetadata ] = & MemoryContractMetadataStore [ DefaultMetadata ] {}
27
+ var _ ContractMetadataStore = & MemoryContractMetadataStore {}
28
28
29
29
// MemoryContractMetadataStore implements MutableContractMetadataStore interface.
30
- var _ MutableContractMetadataStore [ DefaultMetadata ] = & MemoryContractMetadataStore [ DefaultMetadata ] {}
30
+ var _ MutableContractMetadataStore = & MemoryContractMetadataStore {}
31
31
32
32
// NewMemoryContractMetadataStore creates a new MemoryContractMetadataStore instance.
33
33
// It is a generic function that takes a type parameter M which must implement the Cloneable interface.
34
- func NewMemoryContractMetadataStore [ M any ] () * MemoryContractMetadataStore [ M ] {
35
- return & MemoryContractMetadataStore [ M ] {Records : []ContractMetadata [ M ] {}}
34
+ func NewMemoryContractMetadataStore () * MemoryContractMetadataStore {
35
+ return & MemoryContractMetadataStore {Records : []ContractMetadata {}}
36
36
}
37
37
38
38
// Get returns the ContractMetadata for the provided key, or an error if no such record exists.
39
- func (s * MemoryContractMetadataStore [ M ] ) Get (key ContractMetadataKey ) (ContractMetadata [ M ] , error ) {
39
+ func (s * MemoryContractMetadataStore ) Get (key ContractMetadataKey ) (ContractMetadata , error ) {
40
40
s .mu .RLock ()
41
41
defer s .mu .RUnlock ()
42
42
43
43
idx := s .indexOf (key )
44
44
if idx == - 1 {
45
- return ContractMetadata [ M ] {}, ErrContractMetadataNotFound
45
+ return ContractMetadata {}, ErrContractMetadataNotFound
46
46
}
47
47
48
48
return s .Records [idx ].Clone ()
49
49
}
50
50
51
51
// Fetch returns a copy of all ContractMetadata in the store.
52
- func (s * MemoryContractMetadataStore [ M ] ) Fetch () ([]ContractMetadata [ M ] , error ) {
52
+ func (s * MemoryContractMetadataStore ) Fetch () ([]ContractMetadata , error ) {
53
53
s .mu .RLock ()
54
54
defer s .mu .RUnlock ()
55
55
56
- records := []ContractMetadata [ M ] {}
56
+ records := []ContractMetadata {}
57
57
for _ , record := range s .Records {
58
58
clone , err := record .Clone ()
59
59
if err != nil {
@@ -68,11 +68,11 @@ func (s *MemoryContractMetadataStore[M]) Fetch() ([]ContractMetadata[M], error)
68
68
// Filter returns a copy of all ContractMetadata in the store that pass all of the provided filters.
69
69
// Filters are applied in the order they are provided.
70
70
// If no filters are provided, all records are returned.
71
- func (s * MemoryContractMetadataStore [ M ] ) Filter (filters ... FilterFunc [ContractMetadataKey , ContractMetadata [ M ]] ) []ContractMetadata [ M ] {
71
+ func (s * MemoryContractMetadataStore ) Filter (filters ... FilterFunc [ContractMetadataKey , ContractMetadata ] ) []ContractMetadata {
72
72
s .mu .RLock ()
73
73
defer s .mu .RUnlock ()
74
74
75
- records := append ([]ContractMetadata [ M ] {}, s .Records ... )
75
+ records := append ([]ContractMetadata {}, s .Records ... )
76
76
for _ , filter := range filters {
77
77
records = filter (records )
78
78
}
@@ -81,7 +81,7 @@ func (s *MemoryContractMetadataStore[M]) Filter(filters ...FilterFunc[ContractMe
81
81
}
82
82
83
83
// indexOf returns the index of the record with the provided key, or -1 if no such record exists.
84
- func (s * MemoryContractMetadataStore [ M ] ) indexOf (key ContractMetadataKey ) int {
84
+ func (s * MemoryContractMetadataStore ) indexOf (key ContractMetadataKey ) int {
85
85
for i , record := range s .Records {
86
86
if record .Key ().Equals (key ) {
87
87
return i
@@ -93,7 +93,7 @@ func (s *MemoryContractMetadataStore[M]) indexOf(key ContractMetadataKey) int {
93
93
94
94
// Add inserts a new record into the store.
95
95
// If a record with the same key already exists, an error is returned.
96
- func (s * MemoryContractMetadataStore [ M ] ) Add (record ContractMetadata [ M ] ) error {
96
+ func (s * MemoryContractMetadataStore ) Add (record ContractMetadata ) error {
97
97
s .mu .Lock ()
98
98
defer s .mu .Unlock ()
99
99
@@ -108,7 +108,7 @@ func (s *MemoryContractMetadataStore[M]) Add(record ContractMetadata[M]) error {
108
108
109
109
// Upsert inserts a new record into the store if no record with the same key already exists.
110
110
// If a record with the same key already exists, it is updated.
111
- func (s * MemoryContractMetadataStore [ M ] ) Upsert (record ContractMetadata [ M ] ) error {
111
+ func (s * MemoryContractMetadataStore ) Upsert (record ContractMetadata ) error {
112
112
s .mu .Lock ()
113
113
defer s .mu .Unlock ()
114
114
@@ -125,7 +125,7 @@ func (s *MemoryContractMetadataStore[M]) Upsert(record ContractMetadata[M]) erro
125
125
// Update edits an existing record whose fields match the primary key elements of the supplied ContractMetadata, with
126
126
// the non-primary-key values of the supplied ContractMetadata.
127
127
// If no such record exists, an error is returned.
128
- func (s * MemoryContractMetadataStore [ M ] ) Update (record ContractMetadata [ M ] ) error {
128
+ func (s * MemoryContractMetadataStore ) Update (record ContractMetadata ) error {
129
129
s .mu .Lock ()
130
130
defer s .mu .Unlock ()
131
131
@@ -140,7 +140,7 @@ func (s *MemoryContractMetadataStore[M]) Update(record ContractMetadata[M]) erro
140
140
141
141
// Delete deletes an existing record whose primary key elements match the supplied ContractMetadata, returning an error if no
142
142
// such record exists.
143
- func (s * MemoryContractMetadataStore [ M ] ) Delete (key ContractMetadataKey ) error {
143
+ func (s * MemoryContractMetadataStore ) Delete (key ContractMetadataKey ) error {
144
144
s .mu .Lock ()
145
145
defer s .mu .Unlock ()
146
146
0 commit comments