Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions ledger/accountdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3830,11 +3830,18 @@ func accountsNewRoundImpl(
}

updatedKVs = make(map[string]persistedKVData, len(kvPairs))
for key, value := range kvPairs {
if value.data != nil {
err = writer.upsertKvPair(key, value.data)
updatedKVs[key] = persistedKVData{value: value.data, round: lastUpdateRound}
for key, mv := range kvPairs {
if mv.data != nil {
// reminder: check oldData for nil here, b/c bytes.Equal conflates nil and "".
if mv.oldData != nil && bytes.Equal(mv.oldData, mv.data) {
continue // changed back within the delta span
}
err = writer.upsertKvPair(key, mv.data)
updatedKVs[key] = persistedKVData{value: mv.data, round: lastUpdateRound}
} else {
if mv.oldData == nil { // Came and went within the delta span
continue
}
err = writer.deleteKvPair(key)
updatedKVs[key] = persistedKVData{value: nil, round: lastUpdateRound}
}
Expand Down
4 changes: 3 additions & 1 deletion ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,9 @@ func TestKVCache(t *testing.T) {
if i < kvCnt/kvsPerBlock {
for j := 0; j < kvsPerBlock; j++ {
name := fmt.Sprintf("%d", curKV)
kvMods[name] = ledgercore.KvValueDelta{Data: nil}
// needs an old data, else optimized away.
// if oldData = "" there is the best chance of a bug, so we use that
kvMods[name] = ledgercore.KvValueDelta{Data: nil, OldData: []byte("")}
curKV++
}
}
Expand Down
1 change: 1 addition & 0 deletions ledger/catchpointtracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ func (ct *catchpointTracker) accountsUpdateBalances(accountsDeltas compactAccoun
continue
}
if mv.oldData != nil {
// reminder: check mv.data for nil here, b/c bytes.Equal conflates nil and "".
if mv.data != nil && bytes.Equal(mv.oldData, mv.data) {
continue // changed back within the delta span
}
Expand Down