txdb: make ps constant.
This commit is contained in:
parent
4893c7dba5
commit
d26787b389
@ -137,9 +137,7 @@ TX.prototype.fromOptions = function fromOptions(options) {
|
||||
|
||||
if (options.ps != null) {
|
||||
assert(utils.isNumber(options.ps));
|
||||
this.ps = this.ts === 0
|
||||
? options.ps
|
||||
: 0;
|
||||
this.ps = options.ps;
|
||||
}
|
||||
|
||||
if (options.height != null) {
|
||||
@ -180,7 +178,6 @@ TX.prototype.setBlock = function setBlock(block, index) {
|
||||
this.block = block.hash('hex');
|
||||
this.height = block.height;
|
||||
this.index = index == null ? -1 : index;
|
||||
this.ps = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -192,7 +189,6 @@ TX.prototype.unsetBlock = function unsetBlock() {
|
||||
this.block = null;
|
||||
this.height = -1;
|
||||
this.index = -1;
|
||||
this.ps = utils.now();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -458,25 +458,22 @@ TXDB.prototype._add = function add(tx, map, callback, force) {
|
||||
|
||||
batch.put('t/' + hash, tx.toExtended());
|
||||
|
||||
if (tx.ts === 0) {
|
||||
if (tx.ts === 0)
|
||||
batch.put('p/' + hash, DUMMY);
|
||||
batch.put('m/' + pad32(tx.ps) + '/' + hash, DUMMY);
|
||||
} else {
|
||||
else
|
||||
batch.put('h/' + pad32(tx.height) + '/' + hash, DUMMY);
|
||||
batch.put('m/' + pad32(tx.ts) + '/' + hash, DUMMY);
|
||||
}
|
||||
|
||||
batch.put('m/' + pad32(tx.ps) + '/' + hash, DUMMY);
|
||||
|
||||
for (i = 0; i < map.accounts.length; i++) {
|
||||
path = map.accounts[i];
|
||||
id = path.id + '/' + path.account;
|
||||
batch.put('T/' + id + '/' + hash, DUMMY);
|
||||
if (tx.ts === 0) {
|
||||
if (tx.ts === 0)
|
||||
batch.put('P/' + id + '/' + hash, DUMMY);
|
||||
batch.put('M/' + id + '/' + pad32(tx.ps) + '/' + hash, DUMMY);
|
||||
} else {
|
||||
else
|
||||
batch.put('H/' + id + '/' + pad32(tx.height) + '/' + hash, DUMMY);
|
||||
batch.put('M/' + id + '/' + pad32(tx.ts) + '/' + hash, DUMMY);
|
||||
}
|
||||
batch.put('M/' + id + '/' + pad32(tx.ps) + '/' + hash, DUMMY);
|
||||
}
|
||||
|
||||
// Consume unspent money or add orphans
|
||||
@ -875,22 +872,17 @@ TXDB.prototype._confirm = function _confirm(tx, map, callback, force) {
|
||||
// Tricky - update the tx and coin in storage,
|
||||
// and remove pending flag to mark as confirmed.
|
||||
assert(tx.height >= 0);
|
||||
assert(existing.ps > 0);
|
||||
|
||||
batch.put('t/' + hash, tx.toExtended());
|
||||
|
||||
batch.del('p/' + hash);
|
||||
batch.put('h/' + pad32(tx.height) + '/' + hash, DUMMY);
|
||||
batch.del('m/' + pad32(existing.ps) + '/' + hash);
|
||||
batch.put('m/' + pad32(tx.ts) + '/' + hash, DUMMY);
|
||||
|
||||
for (i = 0; i < map.accounts.length; i++) {
|
||||
path = map.accounts[i];
|
||||
id = path.id + '/' + path.account;
|
||||
batch.del('P/' + id + '/' + hash);
|
||||
batch.put('H/' + id + '/' + pad32(tx.height) + '/' + hash, DUMMY);
|
||||
batch.del('M/' + id + '/' + pad32(existing.ps) + '/' + hash);
|
||||
batch.put('M/' + id + '/' + pad32(tx.ts) + '/' + hash, DUMMY);
|
||||
}
|
||||
|
||||
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
||||
@ -1020,25 +1012,22 @@ TXDB.prototype._remove = function remove(tx, map, callback, force) {
|
||||
|
||||
batch.del('t/' + hash);
|
||||
|
||||
if (tx.ts === 0) {
|
||||
if (tx.ts === 0)
|
||||
batch.del('p/' + hash);
|
||||
batch.del('m/' + pad32(tx.ps) + '/' + hash);
|
||||
} else {
|
||||
else
|
||||
batch.del('h/' + pad32(tx.height) + '/' + hash);
|
||||
batch.del('m/' + pad32(tx.ts) + '/' + hash);
|
||||
}
|
||||
|
||||
batch.del('m/' + pad32(tx.ps) + '/' + hash);
|
||||
|
||||
for (i = 0; i < map.accounts.length; i++) {
|
||||
path = map.accounts[i];
|
||||
id = path.id + '/' + path.account;
|
||||
batch.del('T/' + id + '/' + hash);
|
||||
if (tx.ts === 0) {
|
||||
if (tx.ts === 0)
|
||||
batch.del('P/' + id + '/' + hash);
|
||||
batch.del('M/' + id + '/' + pad32(tx.ps) + '/' + hash);
|
||||
} else {
|
||||
else
|
||||
batch.del('H/' + id + '/' + pad32(tx.height) + '/' + hash);
|
||||
batch.del('M/' + id + '/' + pad32(tx.ts) + '/' + hash);
|
||||
}
|
||||
batch.del('M/' + id + '/' + pad32(tx.ps) + '/' + hash);
|
||||
}
|
||||
|
||||
this.fillHistory(tx, function(err) {
|
||||
@ -1155,7 +1144,7 @@ TXDB.prototype.unconfirm = function unconfirm(hash, callback, force) {
|
||||
|
||||
TXDB.prototype._unconfirm = function unconfirm(tx, map, callback, force) {
|
||||
var self = this;
|
||||
var batch, unlock, hash, height, ts, i, path, id;
|
||||
var batch, unlock, hash, height, i, path, id;
|
||||
|
||||
unlock = this._lock(unconfirm, [tx, map, callback], force);
|
||||
|
||||
@ -1166,7 +1155,6 @@ TXDB.prototype._unconfirm = function unconfirm(tx, map, callback, force) {
|
||||
|
||||
hash = tx.hash('hex');
|
||||
height = tx.height;
|
||||
ts = tx.ts;
|
||||
|
||||
batch = this.db.batch();
|
||||
|
||||
@ -1174,7 +1162,6 @@ TXDB.prototype._unconfirm = function unconfirm(tx, map, callback, force) {
|
||||
return callback(null, false, map);
|
||||
|
||||
tx.height = -1;
|
||||
tx.ps = utils.now();
|
||||
tx.ts = 0;
|
||||
tx.index = -1;
|
||||
tx.block = null;
|
||||
@ -1183,16 +1170,12 @@ TXDB.prototype._unconfirm = function unconfirm(tx, map, callback, force) {
|
||||
|
||||
batch.put('p/' + hash, DUMMY);
|
||||
batch.del('h/' + pad32(height) + '/' + hash);
|
||||
batch.del('m/' + pad32(ts) + '/' + hash);
|
||||
batch.put('m/' + pad32(tx.ps) + '/' + hash, DUMMY);
|
||||
|
||||
for (i = 0; i < map.accounts.length; i++) {
|
||||
path = map.accounts[i];
|
||||
id = path.id + '/' + path.account;
|
||||
batch.put('P/' + id + '/' + hash, DUMMY);
|
||||
batch.del('H/' + id + '/' + pad32(height) + '/' + hash);
|
||||
batch.del('M/' + id + '/' + pad32(ts) + '/' + hash);
|
||||
batch.put('M/' + id + '/' + pad32(tx.ps) + '/' + hash, DUMMY);
|
||||
}
|
||||
|
||||
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user