Always use diskdown 32-byte keys
This commit is contained in:
@@ -13,6 +13,7 @@ import Combined from './store/Combined';
|
||||
// import Scatter from './store/Scatter';
|
||||
|
||||
const LRU_SIZE = 8192;
|
||||
const KEY_LENGTH = 32;
|
||||
|
||||
const l = logger('disk/scatter');
|
||||
const noop = () =>
|
||||
@@ -85,6 +86,20 @@ class DiskDown extends AbstractLevelDOWN {
|
||||
|
||||
process.nextTick(callback);
|
||||
}
|
||||
|
||||
_serializeKey (key: Buffer): Buffer {
|
||||
if (key.length === KEY_LENGTH) {
|
||||
return key;
|
||||
} else if (key.length < KEY_LENGTH) {
|
||||
const paddedKey = Buffer.alloc(KEY_LENGTH);
|
||||
|
||||
paddedKey.set(key, 0);
|
||||
|
||||
return paddedKey;
|
||||
}
|
||||
|
||||
throw new Error(`${key.toString()} too large, expected <= 32 bytes`);
|
||||
}
|
||||
}
|
||||
|
||||
export default function (location: string) {
|
||||
|
||||
Reference in New Issue
Block a user