primitives: use equals instead of equal for consistency.

This commit is contained in:
Christopher Jeffrey 2017-08-09 15:25:01 -07:00
parent 33c32d32c1
commit edebc51d18
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
5 changed files with 22 additions and 9 deletions

View File

@ -393,9 +393,8 @@ HDPrivateKey.prototype.derivePath = function derivePath(path) {
* @returns {Boolean}
*/
HDPrivateKey.prototype.equal = function equal(obj) {
if (!HDPrivateKey.isHDPrivateKey(obj))
return false;
HDPrivateKey.prototype.equals = function equals(obj) {
assert(HDPrivateKey.isHDPrivateKey(obj));
return this.network === obj.network
&& this.depth === obj.depth

View File

@ -315,9 +315,8 @@ HDPublicKey.prototype.derivePath = function derivePath(path) {
* @returns {Boolean}
*/
HDPublicKey.prototype.equal = function equal(obj) {
if (!HDPublicKey.isHDPublicKey(obj))
return false;
HDPublicKey.prototype.equals = function equals(obj) {
assert(HDPublicKey.isHDPublicKey(obj));
return this.network === obj.network
&& this.depth === obj.depth

View File

@ -119,6 +119,21 @@ Address.prototype.isNull = function isNull() {
return true;
};
/**
* Test equality against another address.
* @param {Address} addr
* @returns {Boolean}
*/
Address.prototype.equals = function equals(addr) {
assert(addr instanceof Address);
return this.network === addr.network
&& this.type === addr.type
&& this.version === addr.version
&& this.hash.equals(addr.hash);
};
/**
* Get the address type as a string.
* @returns {String}

View File

@ -85,7 +85,7 @@ SigCache.prototype.has = function has(hash, sig, key) {
if (!entry)
return false;
return entry.equal(sig, key);
return entry.equals(sig, key);
};
/**
@ -138,7 +138,7 @@ function SigCacheEntry(sig, key) {
* @returns {Boolean}
*/
SigCacheEntry.prototype.equal = function equal(sig, key) {
SigCacheEntry.prototype.equals = function equals(sig, key) {
return this.sig.equals(sig) && this.key.equals(key);
};

View File

@ -289,7 +289,7 @@ Account.prototype.pushKey = function pushKey(key) {
if (this.type !== Account.types.MULTISIG)
throw new Error('Cannot add keys to non-multisig wallet.');
if (key.equal(this.accountKey))
if (key.equals(this.accountKey))
throw new Error('Cannot add own key.');
const index = util.binaryInsert(this.keys, key, cmp, true);