Skip to content

Commit 0265c9b

Browse files
committed
Merge pull request bitcoinjs#397 from bitcoinjs/buftools
bufferutils: remove equal, use Buffer.compare
2 parents 5e9710b + f9b99fc commit 0265c9b

File tree

4 files changed

+3
-32
lines changed

4 files changed

+3
-32
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ language: node_js
22
before_install:
33
- "npm install npm -g"
44
node_js:
5-
- "0.11"
6-
- "0.10"
5+
- "0.12"
76
env:
87
- TEST_SUITE=coveralls
98
- TEST_SUITE=integration

src/bufferutils.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,24 +168,13 @@ function varIntBuffer (i) {
168168
return buffer
169169
}
170170

171-
function equal (a, b) {
172-
if (a.length !== b.length) return false
173-
174-
for (var i = 0; i < a.length; ++i) {
175-
if (a[i] !== b[i]) return false
176-
}
177-
178-
return true
179-
}
180-
181171
function reverse (buffer) {
182172
var buffer2 = new Buffer(buffer)
183173
Array.prototype.reverse.call(buffer2)
184174
return buffer2
185175
}
186176

187177
module.exports = {
188-
equal: equal,
189178
pushDataSize: pushDataSize,
190179
readPushDataInt: readPushDataInt,
191180
readUInt64LE: readUInt64LE,

src/transaction_builder.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var assert = require('assert')
2-
var bufferutils = require('./bufferutils')
32
var ops = require('./opcodes')
43
var scripts = require('./scripts')
54

@@ -400,15 +399,15 @@ TransactionBuilder.prototype.sign = function (index, keyPair, redeemScript, hash
400399

401400
// enforce in order signing of public keys
402401
assert(input.pubKeys.some(function (pubKey, i) {
403-
if (!bufferutils.equal(kpPubKey, pubKey)) return false
402+
if (kpPubKey.compare(pubKey) !== 0) return false
404403

405404
assert(!input.signatures[i], 'Signature already exists')
406405

407406
var signature = keyPair.sign(signatureHash)
408407
input.signatures[i] = signature
409408

410409
return true
411-
}, this), 'key pair cannot sign for this input')
410+
}), 'key pair cannot sign for this input')
412411
}
413412

414413
module.exports = TransactionBuilder

test/bufferutils.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,6 @@ describe('bufferutils', function () {
8888
})
8989
})
9090

91-
describe('equal', function () {
92-
fixtures.valid.forEach(function (f) {
93-
describe('for ' + f.hexVI, function () {
94-
fixtures.valid.forEach(function (f2) {
95-
it('equates the string comparison: ' + f.hexVI + ' === ' + f2.hexVI, function () {
96-
var a = new Buffer(f.hexVI, 'hex')
97-
var b = new Buffer(f2.hexVI, 'hex')
98-
var expected = f.hexVI === f2.hexVI
99-
100-
assert.equal(bufferutils.equal(a, b), expected)
101-
})
102-
})
103-
})
104-
})
105-
})
106-
10791
describe('reverse', function () {
10892
fixtures.valid.forEach(function (f) {
10993
it('reverses ' + f.hex64 + ' correctly', function () {

0 commit comments

Comments
 (0)