diff --git a/lib/database.js b/lib/database.js index 40761ff..f183864 100644 --- a/lib/database.js +++ b/lib/database.js @@ -85,23 +85,27 @@ function update_address(hash, blockheight, txid, amount, type, cb) { if (err) { return cb(err); } else { - AddressTx.findOneAndUpdate({a_id: hash, txid: txid}, { - $set: { - a_id: hash, - balance: address.balance, - blockindex: blockheight, - txid: txid - } - }, { - new: true, - upsert: true - }, function (err,addresstx) { - if (err) { - return cb(err); - } else { - return cb(); - } - }); + if ( hash != 'coinbase' ) { + AddressTx.findOneAndUpdate({a_id: hash, txid: txid}, { + $set: { + a_id: hash, + blockindex: blockheight, + txid: txid, + amount: address.balance + } + }, { + new: true, + upsert: true + }, function (err,addresstx) { + if (err) { + return cb(err); + } else { + return cb(); + } + }); + } else { + return cb(); + } } }); } diff --git a/models/addresstx.js b/models/addresstx.js index 9e873d7..c1fdb10 100644 --- a/models/addresstx.js +++ b/models/addresstx.js @@ -5,7 +5,7 @@ var AddressTXSchema = new Schema({ a_id: { type: String, index: true}, blockindex: {type: Number, default: 0, index: true}, txid: { type: String, lowercase: true, index: true}, - balance: { type: Number, default: 0} + amount: { type: Number, default: 0} }, {id: false}); module.exports = mongoose.model('AddressTx', AddressTXSchema); \ No newline at end of file