Пример #1
0
        public List <MiningPool> GetAllMiningPools()
        {
            MiningPoolDac miningPoolDac = new MiningPoolDac();
            var           result        = miningPoolDac.GetAllMiningPools();

            return(result);
        }
Пример #2
0
        public MiningMsg CreateNewMiningPool(string minerName, string publicKey)
        {
            MiningPoolDac miningPoolDac    = new MiningPoolDac();
            MiningMsg     newMiningPoolMsg = new MiningMsg();

            newMiningPoolMsg.Name      = minerName;
            newMiningPoolMsg.PublicKey = publicKey;
            return(newMiningPoolMsg);
        }
Пример #3
0
        public void UpdateMiningPools(List <MiningMsg> miningMsgs)
        {
            MiningPoolDac    miningPoolDac   = new MiningPoolDac();
            List <MiningMsg> needUpdateItems = null;
            List <MiningMsg> needAddItems    = null;

            GetItemsUpdate(miningMsgs, out needUpdateItems, out needAddItems);

            var updateItems = needUpdateItems.Select(x => ConvertToMiningPool(x));

            miningPoolDac.UpdateMiningPools(updateItems);

            var addItems = needAddItems.Select(x => ConvertToMiningPool(x));

            miningPoolDac.SaveToDB(addItems);
        }
Пример #4
0
        public bool AddMiningToPool(MiningMsg msg)
        {
            if (!POC.VerifyMiningPoolSignature(msg.PublicKey, msg.Signature))
            {
                return(false);
            }

            var result = false;
            var item   = currentMiningPools.FirstOrDefault(x => x.PublicKey == msg.PublicKey && x.Signature == msg.Signature);

            if (item == null)
            {
                MiningPoolDac miningPoolDac = new MiningPoolDac();
                MiningPool    miningPool    = ConvertToMiningPool(msg);
                result = miningPoolDac.SaveToDB(miningPool) > 0;
            }
            else if (item.Name != msg.Name)
            {
                MiningPoolDac miningPoolDac = new MiningPoolDac();
                MiningPool    miningPool    = new MiningPool()
                {
                    Name = msg.Name, PublicKey = msg.PublicKey, Signature = msg.Signature
                };
                miningPoolDac.UpdateMiningPool(miningPool);
                result = true;
            }
            if (result && OnNewMiningPoolHandle != null)
            {
                NewMiningPoolMsg newMsg = new NewMiningPoolMsg();
                newMsg.MinerInfo = new MiningMsg()
                {
                    Name = msg.Name, PublicKey = msg.PublicKey, Signature = msg.Signature
                };
                OnNewMiningPoolHandle(newMsg);
            }

            return(false);
        }
Пример #5
0
        public MiningPoolComponent()
        {
            MiningPoolDac miningPoolDac = new MiningPoolDac();

            currentMiningPools = miningPoolDac.GetAllMiningPools();
        }