Skip to content

Commit cd68f54

Browse files
committed
address comments
1 parent dd14c56 commit cd68f54

File tree

9 files changed

+20
-16
lines changed

9 files changed

+20
-16
lines changed

core/felt/address.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,3 @@ func (a *Address) Unmarshal(e []byte) {
2929
func (a *Address) SetBytesCanonical(data []byte) error {
3030
return (*Felt)(a).SetBytesCanonical(data)
3131
}
32-
33-
func (a *Address) IsZero() bool {
34-
return (*Felt)(a).IsZero()
35-
}
36-
37-
func (a *Address) Equal(b *Address) bool {
38-
return (*Felt)(a).Equal((*Felt)(b))
39-
}

core/felt/utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package felt
2+
3+
func IsZero[F FeltLike](v *F) bool {
4+
f := Felt(*v)
5+
return f.IsZero()
6+
}
7+
8+
func Equal[F FeltLike](a, b *F) bool {
9+
fa := Felt(*a)
10+
fb := Felt(*b)
11+
return fa.Equal(&fb)
12+
}

core/trie2/triedb/hashdb/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (d *Database) readNode(
8686
func (d *Database) NewIterator(id trieutils.TrieID) (db.Iterator, error) {
8787
key := id.Bucket().Key()
8888
owner := id.Owner()
89-
if !owner.Equal(&felt.Address{}) {
89+
if !felt.IsZero(&owner) {
9090
oBytes := owner.Bytes()
9191
key = append(key, oBytes[:]...)
9292
}

core/trie2/triedb/hashdb/dirty_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (c *dirtyCache) putNode(
3131
c.classNodes[keyStr] = node
3232
}
3333

34-
if owner.IsZero() {
34+
if felt.IsZero(owner) {
3535
c.contractNodes[keyStr] = node
3636
} else {
3737
if _, ok := c.contractStorageNodes[*owner]; !ok {
@@ -52,7 +52,7 @@ func (c *dirtyCache) getNode(
5252
return node, ok
5353
}
5454

55-
if owner.IsZero() {
55+
if felt.IsZero(owner) {
5656
node, ok := c.contractNodes[keyStr]
5757
return node, ok
5858
}

core/trie2/triedb/pathdb/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (d *Database) NewIterator(id trieutils.TrieID) (db.Iterator, error) {
9494
)
9595

9696
owner := id.Owner()
97-
if !owner.Equal(&felt.Address{}) {
97+
if !felt.IsZero(&owner) {
9898
ob := owner.Bytes()
9999
ownerBytes = ob[:]
100100
}

core/trie2/triedb/pathdb/layertree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func (t *layerTracker) findNodeInLayer(
254254
return nil, false
255255
}
256256

257-
if owner.IsZero() {
257+
if felt.IsZero(owner) {
258258
if nodeMap, ok := t.contractNodes[*root]; ok {
259259
if node, exists := nodeMap[*path]; exists {
260260
return node.Blob(), true

core/trie2/triedb/pathdb/nodeset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (s *nodeSet) node(
4949
}
5050

5151
// contract trie nodes
52-
if owner.IsZero() {
52+
if felt.IsZero(owner) {
5353
node, ok := s.contractNodes[*path]
5454
return node, ok
5555
}

core/trie2/triedb/rawdb/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (d *Database) readNode(
4848
func (d *Database) NewIterator(id trieutils.TrieID) (db.Iterator, error) {
4949
key := id.Bucket().Key()
5050
owner := id.Owner()
51-
if !owner.Equal(&felt.Address{}) {
51+
if !felt.IsZero(&owner) {
5252
oBytes := owner.Bytes()
5353
key = append(key, oBytes[:]...)
5454
}

core/trie2/triedb/rawdb/database_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func createContractMergeNodeSet(
6262
childSets := make(map[felt.Address]*trienode.NodeSet)
6363

6464
for owner, ownerNodes := range nodes {
65-
if owner.IsZero() {
65+
if felt.IsZero(&owner) {
6666
for path, node := range ownerNodes {
6767
ownerSet.Add(&path, node)
6868
}

0 commit comments

Comments
 (0)