Skip to content

Commit

Permalink
Merge pull request #325 from onflow/fxamacker/rename-id-to-valueid
Browse files Browse the repository at this point in the history
Rename ID to ValueID
  • Loading branch information
fxamacker authored Jul 6, 2023
2 parents 0c5a9e0 + 3fa18fe commit 37f2201
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions array.go
Original file line number Diff line number Diff line change
Expand Up @@ -2372,10 +2372,10 @@ func (a *Array) SlabID() SlabID {
return a.root.SlabID()
}

func (a *Array) ID() ID {
func (a *Array) ValueID() ValueID {
sid := a.SlabID()

var id ID
var id ValueID
copy(id[:], sid.address[:])
copy(id[8:], sid.index[:])

Expand Down
2 changes: 1 addition & 1 deletion array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ func TestArrayID(t *testing.T) {
require.NoError(t, err)

sid := array.SlabID()
id := array.ID()
id := array.ValueID()

require.Equal(t, sid.address[:], id[:8])
require.Equal(t, sid.index[:], id[8:])
Expand Down
4 changes: 2 additions & 2 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -3861,10 +3861,10 @@ func (m *OrderedMap) SlabID() SlabID {
return m.root.SlabID()
}

func (m *OrderedMap) ID() ID {
func (m *OrderedMap) ValueID() ValueID {
sid := m.SlabID()

var id ID
var id ValueID
copy(id[:], sid.address[:])
copy(id[8:], sid.index[:])

Expand Down
2 changes: 1 addition & 1 deletion map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4227,7 +4227,7 @@ func TestMapID(t *testing.T) {
require.NoError(t, err)

sid := m.SlabID()
id := m.ID()
id := m.ValueID()

require.Equal(t, sid.address[:], id[:8])
require.Equal(t, sid.index[:], id[8:])
Expand Down
6 changes: 5 additions & 1 deletion storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ import (

const LedgerBaseStorageSlabPrefix = "$"

type ID [16]byte
// ValueID identifies Array and OrderedMap.
type ValueID [16]byte

type (
Address [8]byte
SlabIndex [8]byte

// SlabID identifies slab in storage.
// SlabID should only be used to retrieve,
// store, and remove slab in storage.
SlabID struct {
address Address
index SlabIndex
Expand Down

0 comments on commit 37f2201

Please sign in to comment.