@@ -55,12 +55,12 @@ export class CheckpointDB extends DB {
55
55
if ( value === null ) {
56
56
batchOp . push ( {
57
57
type : 'del' ,
58
- key : Buffer . from ( key ) ,
58
+ key : Buffer . from ( key , 'hex' ) ,
59
59
} )
60
60
} else {
61
61
batchOp . push ( {
62
62
type : 'put' ,
63
- key : Buffer . from ( key ) ,
63
+ key : Buffer . from ( key , 'hex' ) ,
64
64
value,
65
65
} )
66
66
}
@@ -91,7 +91,7 @@ export class CheckpointDB extends DB {
91
91
async get ( key : Buffer ) : Promise < Buffer | null > {
92
92
// Lookup the value in our cache. We return the latest checkpointed value (which should be the value on disk)
93
93
for ( let index = this . checkpoints . length - 1 ; index >= 0 ; index -- ) {
94
- const value = this . checkpoints [ index ] . keyValueMap . get ( key . toString ( ) )
94
+ const value = this . checkpoints [ index ] . keyValueMap . get ( key . toString ( 'hex' ) )
95
95
if ( value !== undefined ) {
96
96
return value
97
97
}
@@ -109,7 +109,7 @@ export class CheckpointDB extends DB {
109
109
async put ( key : Buffer , val : Buffer ) : Promise < void > {
110
110
if ( this . isCheckpoint ) {
111
111
// put value in cache
112
- this . checkpoints [ this . checkpoints . length - 1 ] . keyValueMap . set ( key . toString ( ) , val )
112
+ this . checkpoints [ this . checkpoints . length - 1 ] . keyValueMap . set ( key . toString ( 'hex' ) , val )
113
113
} else {
114
114
await super . put ( key , val )
115
115
}
@@ -122,7 +122,7 @@ export class CheckpointDB extends DB {
122
122
async del ( key : Buffer ) : Promise < void > {
123
123
if ( this . isCheckpoint ) {
124
124
// delete the value in the current cache
125
- this . checkpoints [ this . checkpoints . length - 1 ] . keyValueMap . set ( key . toString ( ) , null )
125
+ this . checkpoints [ this . checkpoints . length - 1 ] . keyValueMap . set ( key . toString ( 'hex' ) , null )
126
126
} else {
127
127
// delete the value on disk
128
128
await this . _leveldb . del ( key , ENCODING_OPTS )
0 commit comments