Ejemplo n.º 1
0
        private void updateMintGasStatus(string mongodbConnStr, string mongodbDatabase, string txid)
        {
            var                  client        = new MongoClient(mongodbConnStr);
            var                  database      = client.GetDatabase(mongodbDatabase);
            var                  coll          = database.GetCollection <NEP55.MintGas>("MintGas");
            BsonDocument         queryBson     = BsonDocument.Parse("{txid:'" + txid + "',status:1}");
            List <NEP55.MintGas> queryBsonList = coll.Find(queryBson).ToList();

            if (queryBsonList.Count > 0)
            {
                NEP55.MintGas pro = queryBsonList[0];
                pro.status    = 2;
                pro.claimTime = DateTime.Now;

                coll.ReplaceOne(queryBson, pro);
            }
        }
Ejemplo n.º 2
0
        public JObject lockClaimStatus(string mongodbConnStr, string mongodbDatabase, string txid, int n)
        {
            JObject ret        = new JObject();
            bool    result     = false;
            string  findFliter = "{txid:'" + txid + "',status:1}";
            JArray  array      = mh.GetData(mongodbConnStr, mongodbDatabase, "MintGas", findFliter);

            if (array.Count == 0)
            {
                ret.Add("result", result);
                return(ret);
            }

            JObject txOb   = (JObject)array[0];
            int     status = (int)txOb["status"];

            //2:已处理
            if (status == 2)
            {
                ret.Add("result", result);
                return(ret);
            }

            var                  client        = new MongoClient(mongodbConnStr);
            var                  database      = client.GetDatabase(mongodbDatabase);
            var                  coll          = database.GetCollection <NEP55.MintGas>("MintGas");
            BsonDocument         queryBson     = BsonDocument.Parse("{txid:'" + txid + "',status:1}");
            List <NEP55.MintGas> queryBsonList = coll.Find(queryBson).ToList();

            if (queryBsonList.Count > 0)
            {
                NEP55.MintGas pro = queryBsonList[0];
                pro.status    = 2;
                pro.claimTime = DateTime.Now;

                coll.ReplaceOne(queryBson, pro);
                result = true;
            }
            ret.Add("result", result);
            return(ret);
        }
Ejemplo n.º 3
0
        public void getRefundGas(string mongodbConnStr, string mongodbDatabase, string sneoAddr)
        {
            //首先查出所有refund记录
            string findFliter = "{}";
            JArray arrays     = mh.GetData(mongodbConnStr, mongodbDatabase, "operated4C", findFliter);

            Console.WriteLine("***operated4C***");
            foreach (JObject ob in arrays)
            {
                string addr      = (string)ob["addr"];
                string txid      = (string)ob["txid"];
                int    n         = (int)ob["n"];
                int    refundVal = (int)ob["value"];
                int    endHeigth = (int)ob["blockindex"];

                //查询MintGAS是否存在,如果有就不处理
                if (!getMintGasByTxid(mongodbConnStr, mongodbDatabase, txid))
                {
                    Console.WriteLine("***addr***" + addr + "/txid***" + txid);
                    //取值没问题才进行入库
                    int startHeight = getStartHeight(mongodbConnStr, mongodbDatabase, refundVal, addr);
                    Console.WriteLine("***startHeight***" + startHeight);
                    Thread.Sleep(50);
                    if (startHeight > 0)
                    {
                        var client   = new MongoClient(mongodbConnStr);
                        var database = client.GetDatabase(mongodbDatabase);

                        //计算gas
                        decimal       gas           = getCalGas(mongodbConnStr, mongodbDatabase, startHeight, endHeigth, refundVal);
                        NEP55.MintGas mint          = new NEP55.MintGas(startHeight, endHeigth, txid, addr, refundVal, gas, DateTime.Now);
                        var           collectionPro = database.GetCollection <NEP55.MintGas>("MintGas");
                        collectionPro.InsertOne(mint);
                    }
                }
            }
        }