/// <summary>
        /// A private method to process transactions from API and store as ledgers in local data store.
        /// </summary>
        /// <param name="txs">Transactions from API</param>
        /// <returns>None.</returns>
        private async Task ProcessingLedger(ApiTransactionCollections txs)
        {
            if (txs.txs.Count() > 0)
            {
                foreach (var tx in txs.txs)
                {
                    tx.blockheight = await api.GetBlockHeight(tx.blockhash);

                    var record = tx.ToLedger(contract, contractService);
                    if (record != null && !ledger.Exists(Query.EQ("TxId", record.TxId)))
                    {
                        record.Status = ProcessStatus.NotProcessed;
                        ledger.Upsert(record);
                    }
                }
                ledger.EnsureIndex(l => l.TxId);
                ledger.EnsureIndex(l => l.Blockheight);
                ledger.EnsureIndex(l => l.Operation);
                ledger.EnsureIndex(l => l.TokenSenderHash);
                ledger.EnsureIndex(l => l.TokenReceiverHash);
                ledger.EnsureIndex(l => l.Time);
                contract.LastSyncedBlock = txs.txs.Max(t => t.blockheight);
                contractService.UpdateContract(contract);
            }
        }
        public async Task <ApiTransactionCollections> GetAllTransaction(string address, int limitHeight = 0)
        {
            int count = 3;

            while (count >= 0)
            {
                try
                {
                    int i         = 0;
                    int totalPage = 1;
                    ApiTransactionCollections allTxs = new ApiTransactionCollections();
                    allTxs.txs = new List <ApiTransaction>();
                    bool stopLimit = false;
                    while (i < totalPage && !stopLimit)
                    {
                        var result = await client.GetStringAsync($"/api/txs/?address={address}&pageNum={i}");       //not respond when Disconnect

                        var tempTxs = JsonConvert.DeserializeObject <ApiTransactionCollections>(result);
                        totalPage = tempTxs.pagesTotal;
                        foreach (var tx in tempTxs.txs)
                        {
                            var height = await GetBlockHeight(tx.blockhash);

                            if (height > limitHeight)
                            {
                                allTxs.txs.Add(tx);
                            }
                            else
                            {
                                stopLimit = true;
                                break;
                            }
                        }
                        i++;
                    }
                    allTxs.pagesTotal = i;
                    return(allTxs);
                }
                catch (Exception)
                {
                    Thread.Sleep(3000);
                    count--;
                    continue;
                }
            }

            throw new Exception("Cannot connect to API block explorer.");
        }
        public async Task <ApiTransactionCollections> GetAllTransactionByPage(string address, int page = 0)
        {
            ApiTransactionCollections allTxs = new ApiTransactionCollections();

            allTxs.txs = new List <ApiTransaction>();
            var result = await client.GetStringAsync($"/api/txs/?address={address}&pageNum={page}");

            var tempTxs = JsonConvert.DeserializeObject <ApiTransactionCollections>(result);

            return(tempTxs);
            //foreach (var tx in tempTxs.txs)
            //{
            //    allTxs.txs.Add(tx);
            //}
            //allTxs.pagesTotal = page;
            //return allTxs;
        }