コード例 #1
0
        internal JObject getSendGas(string mongodbConnStr, string mongodbDatabase, string addr)
        {
            JObject ret        = new JObject();
            string  findFliter = "{addr:'" + addr + "'}";

            JArray result = mh.GetData(mongodbConnStr, mongodbDatabase, "address_tx", findFliter);

            Dictionary <string, decimal> balance = new Dictionary <string, decimal>();

            foreach (JObject ob in result)
            {
                string txid = (string)ob["txid"];
                balance = processGasTransfer(mongodbConnStr, mongodbDatabase, txid, balance);
            }
            decimal gas_value = 0; //所有gas总值
            JArray  balanceJA = new JArray();

            foreach (KeyValuePair <string, decimal> kv in balance)
            {
                JObject j = new JObject();
                j.Add("addr", kv.Key);
                j.Add("gas", kv.Value);
                //balanceJA.Add(j);
                gas_value += kv.Value;
                mh.insertOne(mongodbConnStr, mongodbDatabase, "HasSendGas", j);
            }
            ret.Add("gas", gas_value);
            return(ret);
        }