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).
|
* Get a coin (unspents only).
|
||||||
* @method
|
* @method
|
||||||
* @private
|
* @private
|
||||||
* @param {Outpoint} outpoint
|
* @param {Outpoint} prevout
|
||||||
* @returns {Promise} - Returns {@link CoinEntry}.
|
* @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 state = this.state;
|
||||||
let key = outpoint.toKey();
|
|
||||||
let hash = outpoint.hash;
|
|
||||||
let index = outpoint.index;
|
|
||||||
let raw;
|
let raw;
|
||||||
|
|
||||||
if (this.options.spv)
|
if (this.options.spv)
|
||||||
@ -885,6 +884,10 @@ ChainDB.prototype.readCoin = async function readCoin(outpoint) {
|
|||||||
ChainDB.prototype.getCoin = async function getCoin(hash, index) {
|
ChainDB.prototype.getCoin = async function getCoin(hash, index) {
|
||||||
let prevout = new Outpoint(hash, index);
|
let prevout = new Outpoint(hash, index);
|
||||||
let coin = await this.readCoin(prevout);
|
let coin = await this.readCoin(prevout);
|
||||||
|
|
||||||
|
if (!coin)
|
||||||
|
return;
|
||||||
|
|
||||||
return coin.toCoin(prevout);
|
return coin.toCoin(prevout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user