public IRpcMethodResult GetTxOutSetInfo() { try { GetTxOutSetInfoOM result = new GetTxOutSetInfoOM(); var blockComponent = new BlockComponent(); var txComponent = new TransactionComponent(); var utxoComponent = new UtxoComponent(); result.height = blockComponent.GetLatestHeight(); result.bestblock = null; if (result.height >= 0) { var bestBlock = blockComponent.GetBlockMsgByHeight(result.height); result.bestblock = bestBlock != null ? bestBlock.Header.Hash : null; } result.transactions = utxoComponent.GetTransactionCounts(); result.txouts = utxoComponent.GetOutputCounts(); long confirmedBalance, unconfirmedBalance; utxoComponent.GetBalanceInDB(out confirmedBalance, out unconfirmedBalance); result.total_amount = confirmedBalance; return(Ok(result)); } catch (CommonException ce) { return(Error(ce.ErrorCode, ce.Message, ce)); } catch (Exception ex) { return(Error(ErrorCode.UNKNOWN_ERROR, ex.Message, ex)); } }
public GetTxOutSetInfoOM GetTotalBalance() { GetTxOutSetInfoOM result = new GetTxOutSetInfoOM(); result.total_amount = UtxoSetDac.Default.GetConfirmedAmount(); result.height = GlobalParameters.LocalHeight; result.bestblock = BlockDac.Default.GetBlockHashByHeight(result.height); return(result); }
public GetTxOutSetInfoOM GetTxOutSetInfo() { GetTxOutSetInfoOM result = new GetTxOutSetInfoOM(); var blockComponent = new BlockComponent(); result.height = GlobalParameters.LocalHeight; result.bestblock = BlockDac.Default.GetBlockHashByHeight(result.height); var accounts = AccountDac.Default.GetMyAccountBook(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var confirmedUtxos = UtxoSetDac.Default.GetMyUnspentUtxoKeys().ToArray(); stopwatch.Stop(); LogHelper.Warn($"[accounts Count] :: {accounts.Count}"); LogHelper.Warn($"[GetMyUnspentUtxoKeys] use time :: {stopwatch.ElapsedMilliseconds}"); var transacionCount = confirmedUtxos.Select(x => x.Split("_")[0]).Distinct().Count(); result.transactions = transacionCount; result.txouts = confirmedUtxos.Count(); result.total_amount = UtxoSetDac.Default.GetConfirmedAmount() - TransactionPoolDac.Default.UseBalanceInPool; return(result); }