walletdb: comments.
This commit is contained in:
parent
4f8e401dbc
commit
648ad0227b
@ -157,7 +157,8 @@ WalletDB.prototype._close = co(function* close() {
|
||||
});
|
||||
|
||||
/**
|
||||
* Write the genesis block as the best hash.
|
||||
* Emit an error.
|
||||
* @private
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -184,8 +185,8 @@ WalletDB.prototype.load = co(function* load() {
|
||||
});
|
||||
|
||||
/**
|
||||
* Write the genesis block as the best hash.
|
||||
* @returns {Promise}
|
||||
* Bind to node events.
|
||||
* @private
|
||||
*/
|
||||
|
||||
WalletDB.prototype.bind = function bind() {
|
||||
@ -225,7 +226,7 @@ WalletDB.prototype.bind = function bind() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the genesis block as the best hash.
|
||||
* Connect to the node server (client required).
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -240,7 +241,7 @@ WalletDB.prototype.connect = co(function* connect() {
|
||||
});
|
||||
|
||||
/**
|
||||
* Write the genesis block as the best hash.
|
||||
* Disconnect from node server (client required).
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -252,7 +253,7 @@ WalletDB.prototype.disconnect = co(function* disconnect() {
|
||||
});
|
||||
|
||||
/**
|
||||
* Write the genesis block as the best hash.
|
||||
* Initialize and write initial sync state.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -286,7 +287,6 @@ WalletDB.prototype.init = co(function* init() {
|
||||
yield this.resetState(tip, false);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Watch addresses and outpoints.
|
||||
* @private
|
||||
@ -391,7 +391,7 @@ WalletDB.prototype.sync = co(function* sync() {
|
||||
/**
|
||||
* Rescan blockchain from a given height.
|
||||
* @private
|
||||
* @param {Number} height
|
||||
* @param {Number?} height
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -719,11 +719,12 @@ WalletDB.prototype.addHash = function addHash(hash) {
|
||||
/**
|
||||
* Add outpoint to local filter.
|
||||
* @private
|
||||
* @param {Buffer} data
|
||||
* @param {Hash} hash
|
||||
* @param {Number} index
|
||||
*/
|
||||
|
||||
WalletDB.prototype.addOutpoint = function addOutpoint(hash, i) {
|
||||
var outpoint = new Outpoint(hash, i);
|
||||
WalletDB.prototype.addOutpoint = function addOutpoint(hash, index) {
|
||||
var outpoint = new Outpoint(hash, index);
|
||||
this.filter.add(outpoint.toRaw());
|
||||
};
|
||||
|
||||
@ -758,9 +759,9 @@ WalletDB.prototype.unregister = function unregister(wallet) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Map wallet label to wallet id.
|
||||
* @param {String} label
|
||||
* @returns {Promise}
|
||||
* Map wallet id to wid.
|
||||
* @param {String} id
|
||||
* @returns {Promise} - Returns {WalletID}.
|
||||
*/
|
||||
|
||||
WalletDB.prototype.getWalletID = co(function* getWalletID(id) {
|
||||
@ -918,6 +919,7 @@ WalletDB.prototype.renameAccount = function renameAccount(account, name) {
|
||||
var wallet = account.wallet;
|
||||
var batch = this.batch(wallet);
|
||||
|
||||
// Remove old wid/name->account index.
|
||||
batch.del(layout.i(account.wid, account.name));
|
||||
|
||||
account.name = name;
|
||||
@ -926,10 +928,10 @@ WalletDB.prototype.renameAccount = function renameAccount(account, name) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Test an api key against a wallet's api key.
|
||||
* Get a wallet with token auth first.
|
||||
* @param {WalletID} wid
|
||||
* @param {String|Buffer} token
|
||||
* @returns {Promise}
|
||||
* @returns {Promise} - Returns {@link Wallet}.
|
||||
*/
|
||||
|
||||
WalletDB.prototype.auth = co(function* auth(wid, token) {
|
||||
@ -1710,13 +1712,13 @@ WalletDB.prototype.unwriteBlockMap = function unwriteBlockMap(wallet, height) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
WalletDB.prototype.getOutpointMap = co(function* getOutpointMap(hash, i) {
|
||||
var data = yield this.db.get(layout.o(hash, i));
|
||||
WalletDB.prototype.getOutpointMap = co(function* getOutpointMap(hash, index) {
|
||||
var data = yield this.db.get(layout.o(hash, index));
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
return OutpointMapRecord.fromRaw(hash, i, data);
|
||||
return OutpointMapRecord.fromRaw(hash, index, data);
|
||||
});
|
||||
|
||||
/**
|
||||
@ -1727,12 +1729,12 @@ WalletDB.prototype.getOutpointMap = co(function* getOutpointMap(hash, i) {
|
||||
* @param {OutpointMapRecord} map
|
||||
*/
|
||||
|
||||
WalletDB.prototype.writeOutpointMap = function writeOutpointMap(wallet, hash, i, map) {
|
||||
WalletDB.prototype.writeOutpointMap = function writeOutpointMap(wallet, hash, index, map) {
|
||||
var batch = this.batch(wallet);
|
||||
|
||||
this.addOutpoint(hash, i);
|
||||
this.addOutpoint(hash, index);
|
||||
|
||||
batch.put(layout.o(hash, i), map.toRaw());
|
||||
batch.put(layout.o(hash, index), map.toRaw());
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1742,9 +1744,9 @@ WalletDB.prototype.writeOutpointMap = function writeOutpointMap(wallet, hash, i,
|
||||
* @param {Number} index
|
||||
*/
|
||||
|
||||
WalletDB.prototype.unwriteOutpointMap = function unwriteOutpointMap(wallet, hash, i) {
|
||||
WalletDB.prototype.unwriteOutpointMap = function unwriteOutpointMap(wallet, hash, index) {
|
||||
var batch = this.batch(wallet);
|
||||
batch.del(layout.o(hash, i));
|
||||
batch.del(layout.o(hash, index));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1895,6 +1897,7 @@ WalletDB.prototype.addBlock = co(function* addBlock(entry, txs) {
|
||||
* Add a block's transactions without a lock.
|
||||
* @private
|
||||
* @param {ChainEntry} entry
|
||||
* @param {TX[]} txs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -2012,6 +2015,7 @@ WalletDB.prototype._removeBlock = co(function* removeBlock(entry) {
|
||||
* Rescan a block.
|
||||
* @private
|
||||
* @param {ChainEntry} entry
|
||||
* @param {TX[]} txs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user