Comparing version 1.0.0 to 1.1.0
@@ -213,2 +213,60 @@ /** | ||
} | ||
}, | ||
hhash160: { | ||
min: Buffer.alloc(20, 0x00), | ||
max: Buffer.alloc(20, 0xff), | ||
dynamic: false, | ||
size(v) { | ||
return 20; | ||
}, | ||
read(k, o) { | ||
assertLen(o + 20 <= k.length); | ||
return k.toString('hex', o, o + 20); | ||
}, | ||
write(k, v, o) { | ||
assertType(writeHex(k, v, o) === 20); | ||
return 20; | ||
} | ||
}, | ||
hhash256: { | ||
min: Buffer.alloc(32, 0x00), | ||
max: Buffer.alloc(32, 0xff), | ||
dynamic: false, | ||
size(v) { | ||
return 32; | ||
}, | ||
read(k, o) { | ||
assertLen(o + 32 <= k.length); | ||
return k.toString('hex', o, o + 32); | ||
}, | ||
write(k, v, o) { | ||
assertType(writeHex(k, v, o) === 32); | ||
return 32; | ||
} | ||
}, | ||
hhash: { | ||
min: Buffer.alloc(1, 0x00), | ||
max: Buffer.alloc(64, 0xff), | ||
dynamic: true, | ||
size(v) { | ||
return 1 + sizeHex(v); | ||
}, | ||
read(k, o) { | ||
assertLen(o + 1 <= k.length); | ||
assertLen(k[o] >= 1 && k[o] <= 64); | ||
assertLen(o + 1 + k[o] <= k.length); | ||
return k.toString('hex', o + 1, o + 1 + k[o]); | ||
}, | ||
write(k, v, o) { | ||
const size = sizeHex(v); | ||
assertType(size >= 1 && size <= 64); | ||
assertLen(o + 1 <= k.length); | ||
k[o] = size; | ||
assertType(writeHex(k, v, o + 1) === size); | ||
return 1 + size; | ||
} | ||
} | ||
@@ -463,2 +521,16 @@ }; | ||
function sizeHex(data) { | ||
if (Buffer.isBuffer(data)) | ||
return data.length; | ||
assertType(typeof data === 'string'); | ||
return data.length >>> 1; | ||
} | ||
function writeHex(data, str, off) { | ||
if (Buffer.isBuffer(str)) | ||
return str.copy(data, off); | ||
assertType(typeof str === 'string'); | ||
return data.write(str, off, 'hex'); | ||
} | ||
function assertLen(ok) { | ||
@@ -465,0 +537,0 @@ if (!ok) { |
{ | ||
"name": "bdb", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Database for bcoin", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2915423
3706