added get segments by hash prefix

This commit is contained in:
Joe Dowd
2020-08-31 00:45:06 +01:00
parent 26c72b006c
commit 1a06502806
7 changed files with 206 additions and 198 deletions

View File

@@ -0,0 +1,11 @@
const config = require('../config.js');
const logger = require('./logger.js');
const minimumPrefix = config.minimumPrefix || '3';
const maximumPrefix = config.maximumPrefix || '32'; // Half the hash.
const prefixChecker = new RegExp('^[\\da-f]{' + minimumPrefix + ',' + maximumPrefix + '}$', 'i');
module.exports = (prefix) => {
return prefixChecker.test(prefix);
};