示例#1
0
        private void process()
        {
            // 已对账高度
            int lmax = getLmax();

            // 最新高度
            int rmax = getRmax();

            if (lmax >= rmax)
            {
                LogHelper.debug(string.Format("{0} has processed at {1}/{2}", name(), lmax, rmax));
                return;
            }

            // 获取参与竞拍地址列表
            List <string> addrs = MongoDBHelperExtra.getAuctionAddrList(mongodbConnStr, mongodbDatabase, auctionStateCol, lmax, rmax, bonusAddr);

            if (addrs == null || addrs.Count == 0)
            {
                updateRecord(rmax);
                LogHelper.debug(string.Format("{0} has processed at {1}/{2}", name(), lmax, rmax));
                return;
            }

            // 获取地址余额(cc vs db)
            addrs.ForEach(p =>
            {
                string addr = p;
                //
                decimal d1 = balanceOf(addr);

                decimal d2 = MongoDBHelperExtra.queryAddrBalance(mongodbConnStr, mongodbDatabase, cgasBalanceCol, addr, regscripthash);

                if (d1 != d2)
                {
                    //Console.WriteLine("{0}-->{1} -> {2}", addr, d1, d2);
                    string msg = String.Format("addr={0},smBalance={1},dbBalance={2}", addr, d1, d2);
                    addrBalanceQueue.Add(msg);
                }
            });

            // 获取地址竞拍余额(cc vs db)
            addrs.ForEach(p => {
                string addr = p;
                //
                List <string> list = MongoDBHelperExtra.getAuctionAddrIdList(mongodbConnStr, mongodbDatabase, auctionStateCol, lmax, rmax, addr);
                if (list == null || list.Count == 0)
                {
                    return;
                }

                list.ForEach(pk => {
                    string id = pk;

                    decimal d1 = balanceOfBid(addr, id);

                    decimal d2 = MongoDBHelperExtra.queryAddrIdBalance(mongodbConnStr, mongodbDatabase, auctionStateCol, addr, id);
                    if (d1 != d2)
                    {
                        //Console.WriteLine("{0}-->{1} -> {2}-> {3}", addr, id, d1, d2);
                        string msg = String.Format("addr={0},auctionId={1},smBalance={2},dbBalance={3}", addr, id, d1, d2);
                        addrIdBalanceQueue.Add(msg);
                    }
                });
            });

            //addrBalanceQueue.Add(string.Format("\taddr={0},auctionId={1},smBalance={2},dbBalance={3}", 1,1,1,1));
            //addrIdBalanceQueue.Add(string.Format("\taddr={0},auctionId={1},smBalance={2},dbBalance={3}", 1,1,1,1));
            // 发送
            StringBuilder sb = new StringBuilder();

            sb.Append("\n1.注册器下账户地址余额对比:");
            foreach (var it in addrBalanceQueue.ToArray())
            {
                sb.Append("\n\t").Append(it);
            }
            sb.Append("\n2.注册器下账户地址竞拍余额对比:");
            foreach (var it in addrIdBalanceQueue)
            {
                sb.Append("\n\t").Append(it);
            }
            Console.WriteLine(sb.ToString());
            mkc.sendToListener(sb.ToString());
            while (addrBalanceQueue.Count > 0)
            {
                addrBalanceQueue.Take();
            }
            while (addrIdBalanceQueue.Count > 0)
            {
                addrIdBalanceQueue.Take();
            }


            // 更新高度
            updateRecord(rmax);
            LogHelper.debug(string.Format("{0} has processed at {1}/{2}", name(), lmax, rmax));
        }
示例#2
0
 private static int getRmax()
 {
     return(MongoDBHelperExtra.getRmax(mongodbConnStr, mongodbDatabase, auctionStateCol));
 }