fix toHex use
This commit is contained in:
parent
966b8988e1
commit
4da3285930
|
@ -52,7 +52,7 @@ function spec(b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setupHandlers();
|
this.setupHandlers();
|
||||||
};
|
}
|
||||||
Connection.superclass = b.superclass || require('events').EventEmitter;
|
Connection.superclass = b.superclass || require('events').EventEmitter;
|
||||||
|
|
||||||
Connection.prototype.setupHandlers = function () {
|
Connection.prototype.setupHandlers = function () {
|
||||||
|
@ -63,8 +63,8 @@ function spec(b) {
|
||||||
var dumpLen = 35;
|
var dumpLen = 35;
|
||||||
log.debug('['+this.peer+'] '+
|
log.debug('['+this.peer+'] '+
|
||||||
'Recieved '+data.length+' bytes of data:');
|
'Recieved '+data.length+' bytes of data:');
|
||||||
log.debug('... '+ data.slice(0, dumpLen > data.length ?
|
log.debug('... '+ buffertools.toHex(data.slice(0, dumpLen > data.length ?
|
||||||
data.length : dumpLen).toHex() +
|
data.length : dumpLen)) +
|
||||||
(data.length > dumpLen ? '...' : ''));
|
(data.length > dumpLen ? '...' : ''));
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
this.socket.addListener('data', this.handleData.bind(this));
|
this.socket.addListener('data', this.handleData.bind(this));
|
||||||
|
|
|
@ -798,13 +798,13 @@ function spec(b) {
|
||||||
ScriptInterpreter.prototype.getPrimitiveStack = function getPrimitiveStack() {
|
ScriptInterpreter.prototype.getPrimitiveStack = function getPrimitiveStack() {
|
||||||
return this.stack.map(function (entry) {
|
return this.stack.map(function (entry) {
|
||||||
if (entry.length > 2) {
|
if (entry.length > 2) {
|
||||||
return entry.slice(0).toHex();
|
return buffertools.toHex(entry.slice(0));
|
||||||
}
|
}
|
||||||
var num = castBigint(entry);
|
var num = castBigint(entry);
|
||||||
if (num.cmp(-128) >= 0 && num.cmp(127) <= 0) {
|
if (num.cmp(-128) >= 0 && num.cmp(127) <= 0) {
|
||||||
return num.toNumber();
|
return num.toNumber();
|
||||||
} else {
|
} else {
|
||||||
return entry.slice(0).toHex();
|
return buffertools.toHex(entry.slice(0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,6 @@ var sha256ripe160 = exports.sha256ripe160 = function (data) {
|
||||||
* Format a block hash like the official client does.
|
* Format a block hash like the official client does.
|
||||||
*/
|
*/
|
||||||
var formatHash = exports.formatHash = function (hash) {
|
var formatHash = exports.formatHash = function (hash) {
|
||||||
// Make a copy, because reverse() and toHex() are destructive.
|
|
||||||
var hashEnd = new Buffer(10);
|
var hashEnd = new Buffer(10);
|
||||||
hash.copy(hashEnd, 0, 22, 32);
|
hash.copy(hashEnd, 0, 22, 32);
|
||||||
return buffertools.reverse(hashEnd).toString('hex');
|
return buffertools.reverse(hashEnd).toString('hex');
|
||||||
|
@ -39,10 +38,9 @@ var formatHash = exports.formatHash = function (hash) {
|
||||||
* Display the whole hash, as hex, in correct endian order.
|
* Display the whole hash, as hex, in correct endian order.
|
||||||
*/
|
*/
|
||||||
var formatHashFull = exports.formatHashFull = function (hash) {
|
var formatHashFull = exports.formatHashFull = function (hash) {
|
||||||
// Make a copy, because reverse() and toHex() are destructive.
|
|
||||||
var copy = new Buffer(hash.length);
|
var copy = new Buffer(hash.length);
|
||||||
hash.copy(copy);
|
hash.copy(copy);
|
||||||
var hex = buffertools.reverse(copy).toHex();
|
var hex = buffertools.toHex(buffertools.reverse(copy));
|
||||||
return hex;
|
return hex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,7 +69,7 @@ var formatBuffer = exports.formatBuffer = function (buffer, maxLen) {
|
||||||
buffer.copy(temp, 0, 0, maxLen);
|
buffer.copy(temp, 0, 0, maxLen);
|
||||||
|
|
||||||
// Format as string
|
// Format as string
|
||||||
var output = temp.toHex();
|
var output = buffertools.toHex(temp);
|
||||||
if (temp.length < buffer.length) {
|
if (temp.length < buffer.length) {
|
||||||
output += "...";
|
output += "...";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue