Skip to content

Commit 308cf46

Browse files
author
abstrct
committed
struct type refactoring
1 parent 00e1b6d commit 308cf46

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package keeper
2+
3+
import (
4+
"structs/x/structs/types"
5+
)
6+
7+
// GetStructType returns a StructType by ID, caching the result
8+
func (cc *CurrentContext) GetStructType(structTypeId uint64) (*StructTypeCache, bool) {
9+
if cache, exists := cc.structTypes[structTypeId]; exists {
10+
return cache, true
11+
}
12+
13+
structType, structTypeFound := cc.k.GetStructType(cc.ctx, structTypeId)
14+
if !structTypeFound {
15+
return &StructTypeCache{}, structTypeFound
16+
}
17+
18+
cc.structTypes[structTypeId] = &StructTypeCache{
19+
StructTypeId: structTypeId,
20+
CC: cc,
21+
StructType: structType,
22+
}
23+
return cc.structTypes[structTypeId], structTypeFound
24+
}

0 commit comments

Comments
 (0)