more parsing.
This commit is contained in:
parent
ce0294f4bf
commit
f564ef5735
@ -101,8 +101,6 @@ workers.call = function call(method, args, callback) {
|
||||
*/
|
||||
|
||||
bcoin.tx.prototype.verifyAsync = function verifyAsync(index, force, flags, callback) {
|
||||
var tx;
|
||||
|
||||
callback = utils.asyncify(callback);
|
||||
|
||||
if (!force && this.ts !== 0)
|
||||
@ -114,11 +112,7 @@ bcoin.tx.prototype.verifyAsync = function verifyAsync(index, force, flags, callb
|
||||
if (this.isCoinbase())
|
||||
return callback(null, true);
|
||||
|
||||
// Important: we need to serialize
|
||||
// the coins for the worker.
|
||||
tx = this.toExtended(true);
|
||||
|
||||
return workers.call('verify', [tx, index, force, flags], callback);
|
||||
return workers.call('verify', [this, index, force, flags], callback);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -178,7 +172,7 @@ function createPacket(id, name, items) {
|
||||
|
||||
function createBody(name, items) {
|
||||
var p = new BufferWriter();
|
||||
var i;
|
||||
var i, item;
|
||||
|
||||
if (name)
|
||||
p.writeVarString(name, 'ascii');
|
||||
@ -188,33 +182,38 @@ function createBody(name, items) {
|
||||
p.writeUIntv(items.length);
|
||||
|
||||
for (i = 0; i < items.length; i++) {
|
||||
switch (typeof items[i]) {
|
||||
item = items[i];
|
||||
switch (typeof item) {
|
||||
case 'string':
|
||||
p.writeU8(1);
|
||||
p.writeVarString(items[i], 'utf8');
|
||||
p.writeVarString(item, 'utf8');
|
||||
break;
|
||||
case 'number':
|
||||
p.writeU8(2);
|
||||
p.write32(items[i]);
|
||||
p.write32(item);
|
||||
break;
|
||||
case 'boolean':
|
||||
p.writeU8(3);
|
||||
p.writeU8(items[i] ? 1 : 0);
|
||||
p.writeU8(item ? 1 : 0);
|
||||
break;
|
||||
case 'object':
|
||||
case 'undefined':
|
||||
if (items[i] == null) {
|
||||
if (item == null) {
|
||||
p.writeU8(0);
|
||||
} else if (Buffer.isBuffer(items[i])) {
|
||||
p.writeU8(5);
|
||||
p.writeVarBytes(items[i]);
|
||||
} else {
|
||||
p.writeU8(4);
|
||||
p.writeVarString(JSON.stringify(items[i]), 'utf8');
|
||||
if (item.toExtended)
|
||||
item = item.toExtended(true);
|
||||
if (Buffer.isBuffer(item)) {
|
||||
p.writeU8(5);
|
||||
p.writeVarBytes(item);
|
||||
} else {
|
||||
p.writeU8(4);
|
||||
p.writeVarString(JSON.stringify(item), 'utf8');
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false, 'Bad type: ' + (typeof items[i]));
|
||||
assert(false, 'Bad type: ' + typeof item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user