chaindb: fix getCoin.
This commit is contained in:
parent
aa71ae690a
commit
82bdd73f05
@ -844,15 +844,14 @@ ChainDB.prototype.getTips = function getTips() {
|
||||
* Get a coin (unspents only).
|
||||
* @method
|
||||
* @private
|
||||
* @param {Outpoint} outpoint
|
||||
* @param {Outpoint} prevout
|
||||
* @returns {Promise} - Returns {@link CoinEntry}.
|
||||
*/
|
||||
|
||||
ChainDB.prototype.readCoin = async function readCoin(outpoint) {
|
||||
ChainDB.prototype.readCoin = async function readCoin(prevout) {
|
||||
let {hash, index} = prevout;
|
||||
let key = prevout.toKey();
|
||||
let state = this.state;
|
||||
let key = outpoint.toKey();
|
||||
let hash = outpoint.hash;
|
||||
let index = outpoint.index;
|
||||
let raw;
|
||||
|
||||
if (this.options.spv)
|
||||
@ -885,6 +884,10 @@ ChainDB.prototype.readCoin = async function readCoin(outpoint) {
|
||||
ChainDB.prototype.getCoin = async function getCoin(hash, index) {
|
||||
let prevout = new Outpoint(hash, index);
|
||||
let coin = await this.readCoin(prevout);
|
||||
|
||||
if (!coin)
|
||||
return;
|
||||
|
||||
return coin.toCoin(prevout);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user