From bc10f12ad8074d6c5e9f752ed6ed8c81fa8cd728 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Thu, 16 Mar 2023 10:26:44 +0700 Subject: [PATCH] don't loose nil value --- eth/stagedsync/exec3.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/eth/stagedsync/exec3.go b/eth/stagedsync/exec3.go index 5c30b737d7f..7d57320ee8f 100644 --- a/eth/stagedsync/exec3.go +++ b/eth/stagedsync/exec3.go @@ -1213,7 +1213,11 @@ func reconstituteStep(last bool, } lastKey = append(lastKey[:0], k[:len(k)-8]...) } - lastVal = append(lastVal[:0], v...) + if v == nil { // `nil` value means delete, `empty value []byte{}` means empty value + lastVal = nil + } else { + lastVal = append(lastVal[:0], v...) + } return nil }, etl.TransformArgs{}); err != nil { return err @@ -1241,7 +1245,11 @@ func reconstituteStep(last bool, } lastKey = append(lastKey[:0], k[:len(k)-8]...) } - lastVal = append(lastVal[:0], v...) + if v == nil { + lastVal = nil + } else { + lastVal = append(lastVal[:0], v...) + } return nil }, etl.TransformArgs{}); err != nil { return err @@ -1269,7 +1277,11 @@ func reconstituteStep(last bool, } lastKey = append(lastKey[:0], k[:len(k)-8]...) } - lastVal = append(lastVal[:0], v...) + if v == nil { + lastVal = nil + } else { + lastVal = append(lastVal[:0], v...) + } return nil }, etl.TransformArgs{}); err != nil { return err