@@ -82,31 +82,31 @@ type CompactableChonk interface {
8282//
8383// Mem implements the Chonk interface.
8484type Mem struct {
85- l sync.RWMutex
85+ mu sync.RWMutex
8686 aums map [AUMHash ]AUM
8787 parentIndex map [AUMHash ][]AUMHash
8888
8989 lastActiveAncestor * AUMHash
9090}
9191
9292func (c * Mem ) SetLastActiveAncestor (hash AUMHash ) error {
93- c .l .Lock ()
94- defer c .l .Unlock ()
93+ c .mu .Lock ()
94+ defer c .mu .Unlock ()
9595 c .lastActiveAncestor = & hash
9696 return nil
9797}
9898
9999func (c * Mem ) LastActiveAncestor () (* AUMHash , error ) {
100- c .l .RLock ()
101- defer c .l .RUnlock ()
100+ c .mu .RLock ()
101+ defer c .mu .RUnlock ()
102102 return c .lastActiveAncestor , nil
103103}
104104
105105// Heads returns AUMs for which there are no children. In other
106106// words, the latest AUM in all chains (the 'leaf').
107107func (c * Mem ) Heads () ([]AUM , error ) {
108- c .l .RLock ()
109- defer c .l .RUnlock ()
108+ c .mu .RLock ()
109+ defer c .mu .RUnlock ()
110110 out := make ([]AUM , 0 , 6 )
111111
112112 // An AUM is a 'head' if there are no nodes for which it is the parent.
@@ -120,8 +120,8 @@ func (c *Mem) Heads() ([]AUM, error) {
120120
121121// AUM returns the AUM with the specified digest.
122122func (c * Mem ) AUM (hash AUMHash ) (AUM , error ) {
123- c .l .RLock ()
124- defer c .l .RUnlock ()
123+ c .mu .RLock ()
124+ defer c .mu .RUnlock ()
125125 aum , ok := c .aums [hash ]
126126 if ! ok {
127127 return AUM {}, os .ErrNotExist
@@ -132,8 +132,8 @@ func (c *Mem) AUM(hash AUMHash) (AUM, error) {
132132// ChildAUMs returns all AUMs with a specified previous
133133// AUM hash.
134134func (c * Mem ) ChildAUMs (prevAUMHash AUMHash ) ([]AUM , error ) {
135- c .l .RLock ()
136- defer c .l .RUnlock ()
135+ c .mu .RLock ()
136+ defer c .mu .RUnlock ()
137137 out := make ([]AUM , 0 , 6 )
138138 for _ , entry := range c .parentIndex [prevAUMHash ] {
139139 out = append (out , c .aums [entry ])
@@ -147,8 +147,8 @@ func (c *Mem) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) {
147147// as the rest of the TKA implementation assumes that only
148148// verified AUMs are stored.
149149func (c * Mem ) CommitVerifiedAUMs (updates []AUM ) error {
150- c .l .Lock ()
151- defer c .l .Unlock ()
150+ c .mu .Lock ()
151+ defer c .mu .Unlock ()
152152 if c .aums == nil {
153153 c .parentIndex = make (map [AUMHash ][]AUMHash , 64 )
154154 c .aums = make (map [AUMHash ]AUM , 64 )
0 commit comments