hostlist: minor.

This commit is contained in:
Christopher Jeffrey 2017-03-01 11:39:14 -08:00
parent da69c5d888
commit 53f607e19f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -69,6 +69,14 @@ function HostList(options) {
this._init(); this._init();
} }
/**
* Serialization version.
* @const {Number}
* @default
*/
HostList.VERSION = 0;
/** /**
* Initialize options. * Initialize options.
* @private * @private
@ -972,7 +980,7 @@ HostList.prototype.toJSON = function toJSON() {
} }
return { return {
version: 1, version: HostList.VERSION,
addrs: addrs, addrs: addrs,
fresh: fresh, fresh: fresh,
used: used used: used
@ -996,7 +1004,9 @@ HostList.prototype.fromJSON = function fromJSON(json) {
var i, j, bucket, keys, key, addr, entry, src; var i, j, bucket, keys, key, addr, entry, src;
assert(json && typeof json === 'object'); assert(json && typeof json === 'object');
assert(json.version === 1, 'Bad address serialization version.');
assert(json.version === HostList.VERSION,
'Bad address serialization version.');
assert(Array.isArray(json.addrs)); assert(Array.isArray(json.addrs));