Skip to content

Commit

Permalink
Update to new persistence, with seperate key/section namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwood committed Jun 14, 2024
1 parent 8f0b5c5 commit 06a7f5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.2
require (
github.com/shimmeringbee/bytecodec v0.0.0-20240614104652-9d31c74dcd13
github.com/shimmeringbee/logwrap v0.1.3
github.com/shimmeringbee/persistence v0.0.0-20240614122634-f587e84f4d9e
github.com/shimmeringbee/persistence v0.0.0-20240614162125-05e0f3a3a718
github.com/shimmeringbee/retry v0.0.0-20240614104711-064c2726a8b4
github.com/shimmeringbee/unpi v0.0.0-20240614104715-5284f961bafc
github.com/shimmeringbee/zigbee v0.0.0-20240614104723-f4c0c0231568
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/shimmeringbee/persistence v0.0.0-20240614103725-eec3415bbc98 h1:JoPko
github.com/shimmeringbee/persistence v0.0.0-20240614103725-eec3415bbc98/go.mod h1:Z5euPm65BHgTSRFgaWHByaXejU/J4oUqESV9k0VzQDU=
github.com/shimmeringbee/persistence v0.0.0-20240614122634-f587e84f4d9e h1:2D/91t0thwTrZrFhAPqEBwEUJceHbWXujhB1BqTVLFA=
github.com/shimmeringbee/persistence v0.0.0-20240614122634-f587e84f4d9e/go.mod h1:Z5euPm65BHgTSRFgaWHByaXejU/J4oUqESV9k0VzQDU=
github.com/shimmeringbee/persistence v0.0.0-20240614162125-05e0f3a3a718 h1:iX4hgz0ye0t2ZR+ny3O8U8vQGW2TSm4x7jY0YdqNiCM=
github.com/shimmeringbee/persistence v0.0.0-20240614162125-05e0f3a3a718/go.mod h1:Z5euPm65BHgTSRFgaWHByaXejU/J4oUqESV9k0VzQDU=
github.com/shimmeringbee/retry v0.0.0-20221006193055-2ce01bf139c2 h1:HxpPz7w7SxVf1GmcM5oTK1JK64TGpK1UflweYRSOwC4=
github.com/shimmeringbee/retry v0.0.0-20221006193055-2ce01bf139c2/go.mod h1:KYvVq5b7/BSSlWng+AKB5jwNGpc0D7eg8ySWrdPAlms=
github.com/shimmeringbee/retry v0.0.0-20240614104711-064c2726a8b4 h1:YU77guV/6/9nJymm4K1JH6MIx6yE/NfUnFX//yo3GfM=
Expand Down
4 changes: 2 additions & 2 deletions node_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (t *nodeTable) remove(ieeeAddress zigbee.IEEEAddress) {
delete(t.ieeeToNode, node.IEEEAddress)
}

t.p.Delete(ieeeAddress.String())
t.p.DeleteSection(ieeeAddress.String())
}

func (t *nodeTable) load() {
Expand All @@ -155,7 +155,7 @@ func (t *nodeTable) load() {
t.lock.Unlock()
}()

for _, key := range t.p.Keys() {
for _, key := range t.p.SectionKeys() {
if value, err := strconv.ParseUint(key, 16, 64); err == nil {
s := t.p.Section(key)
ieee := zigbee.IEEEAddress(value)
Expand Down
6 changes: 3 additions & 3 deletions node_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestNodeTable(t *testing.T) {
assert.Equal(t, network, node.NetworkAddress)
assert.Equal(t, zigbee.Unknown, node.LogicalType)

assert.Contains(t, s.Keys(), ieee.String())
assert.Contains(t, s.SectionKeys(), ieee.String())

ns := s.Section(ieee.String())
na, ok := converter.Retrieve(ns, "NetworkAddress", converter.NetworkAddressDecoder)
Expand Down Expand Up @@ -91,10 +91,10 @@ func TestNodeTable(t *testing.T) {
nt := newNodeTable(s)

nt.addOrUpdate(ieee, network)
assert.Contains(t, s.Keys(), ieee.String())
assert.Contains(t, s.SectionKeys(), ieee.String())

nt.remove(ieee)
assert.NotContains(t, s.Keys(), ieee.String())
assert.NotContains(t, s.SectionKeys(), ieee.String())

_, found := nt.getByNetwork(network)
assert.False(t, found)
Expand Down

0 comments on commit 06a7f5a

Please sign in to comment.