diff --git a/api/worker.go b/api/worker.go index 786c2920..b2032c58 100644 --- a/api/worker.go +++ b/api/worker.go @@ -121,7 +121,7 @@ func (w *Worker) GetTransaction(txid string, spendingTxs bool, specificJSON bool } // GetTransactionFromBchainTx reads transaction data from txid -func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32, spendingTxs bool, specificJSON bool) (*Tx, error) { +func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spendingTxs bool, specificJSON bool) (*Tx, error) { var err error var ta *db.TxAddresses var tokens []TokenTransfer @@ -134,7 +134,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32, return nil, errors.Annotatef(err, "GetTxAddresses %v", bchainTx.Txid) } } - blockhash, err = w.db.GetBlockHash(height) + blockhash, err = w.db.GetBlockHash(uint32(height)) if err != nil { return nil, errors.Annotatef(err, "GetBlockHash %v", height) } @@ -236,7 +236,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32, if ta != nil { vout.Spent = ta.Outputs[i].Spent if spendingTxs && vout.Spent { - err = w.setSpendingTxToVout(vout, bchainTx.Txid, height) + err = w.setSpendingTxToVout(vout, bchainTx.Txid, uint32(height)) if err != nil { glog.Errorf("setSpendingTxToVout error %v, %v, output %v", err, vout.AddrDesc, vout.N) } @@ -312,7 +312,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32, } r := &Tx{ Blockhash: blockhash, - Blockheight: int(height), + Blockheight: height, Blocktime: bchainTx.Blocktime, Confirmations: bchainTx.Confirmations, FeesSat: (*Amount)(&feesSat), diff --git a/db/txcache.go b/db/txcache.go index c4c45c47..885a315f 100644 --- a/db/txcache.go +++ b/db/txcache.go @@ -36,7 +36,7 @@ func NewTxCache(db *RocksDB, chain bchain.BlockChain, metrics *common.Metrics, i // GetTransaction returns transaction either from RocksDB or if not present from blockchain // it the transaction is confirmed, it is stored in the RocksDB -func (c *TxCache) GetTransaction(txid string) (*bchain.Tx, uint32, error) { +func (c *TxCache) GetTransaction(txid string) (*bchain.Tx, int, error) { var tx *bchain.Tx var h uint32 var err error @@ -50,7 +50,7 @@ func (c *TxCache) GetTransaction(txid string) (*bchain.Tx, uint32, error) { _, bestheight, _ := c.is.GetSyncState() tx.Confirmations = bestheight - h + 1 c.metrics.TxCacheEfficiency.With(common.Labels{"status": "hit"}).Inc() - return tx, h, nil + return tx, int(h), nil } } tx, err = c.chain.GetTransaction(txid) @@ -97,7 +97,7 @@ func (c *TxCache) GetTransaction(txid string) (*bchain.Tx, uint32, error) { } } } else { - h = 0 + return tx, -1, nil } - return tx, h, nil + return tx, int(h), nil }