Skip to content

Commit

Permalink
fix toHex use
Browse files Browse the repository at this point in the history
  • Loading branch information
maraoz committed Feb 18, 2014
1 parent 966b898 commit 4da3285
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function spec(b) {
}

this.setupHandlers();
};
}
Connection.superclass = b.superclass || require('events').EventEmitter;

Connection.prototype.setupHandlers = function () {
Expand All @@ -63,8 +63,8 @@ function spec(b) {
var dumpLen = 35;
log.debug('['+this.peer+'] '+
'Recieved '+data.length+' bytes of data:');
log.debug('... '+ data.slice(0, dumpLen > data.length ?
data.length : dumpLen).toHex() +
log.debug('... '+ buffertools.toHex(data.slice(0, dumpLen > data.length ?
data.length : dumpLen)) +
(data.length > dumpLen ? '...' : ''));
}).bind(this));
this.socket.addListener('data', this.handleData.bind(this));
Expand Down
4 changes: 2 additions & 2 deletions ScriptInterpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,13 @@ function spec(b) {
ScriptInterpreter.prototype.getPrimitiveStack = function getPrimitiveStack() {
return this.stack.map(function (entry) {
if (entry.length > 2) {
return entry.slice(0).toHex();
return buffertools.toHex(entry.slice(0));
}
var num = castBigint(entry);
if (num.cmp(-128) >= 0 && num.cmp(127) <= 0) {
return num.toNumber();
} else {
return entry.slice(0).toHex();
return buffertools.toHex(entry.slice(0));
}
});
};
Expand Down
6 changes: 2 additions & 4 deletions util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var sha256ripe160 = exports.sha256ripe160 = function (data) {
* Format a block hash like the official client does.
*/
var formatHash = exports.formatHash = function (hash) {
// Make a copy, because reverse() and toHex() are destructive.
var hashEnd = new Buffer(10);
hash.copy(hashEnd, 0, 22, 32);
return buffertools.reverse(hashEnd).toString('hex');
Expand All @@ -39,10 +38,9 @@ var formatHash = exports.formatHash = function (hash) {
* Display the whole hash, as hex, in correct endian order.
*/
var formatHashFull = exports.formatHashFull = function (hash) {
// Make a copy, because reverse() and toHex() are destructive.
var copy = new Buffer(hash.length);
hash.copy(copy);
var hex = buffertools.reverse(copy).toHex();
var hex = buffertools.toHex(buffertools.reverse(copy));
return hex;
};

Expand Down Expand Up @@ -71,7 +69,7 @@ var formatBuffer = exports.formatBuffer = function (buffer, maxLen) {
buffer.copy(temp, 0, 0, maxLen);

// Format as string
var output = temp.toHex();
var output = buffertools.toHex(temp);
if (temp.length < buffer.length) {
output += "...";
}
Expand Down

0 comments on commit 4da3285

Please sign in to comment.