public List <MiningPool> GetAllMiningPools() { MiningPoolDac miningPoolDac = new MiningPoolDac(); var result = miningPoolDac.GetAllMiningPools(); return(result); }
public MiningMsg CreateNewMiningPool(string minerName, string publicKey) { MiningPoolDac miningPoolDac = new MiningPoolDac(); MiningMsg newMiningPoolMsg = new MiningMsg(); newMiningPoolMsg.Name = minerName; newMiningPoolMsg.PublicKey = publicKey; return(newMiningPoolMsg); }
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); }
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); }
public MiningPoolComponent() { MiningPoolDac miningPoolDac = new MiningPoolDac(); currentMiningPools = miningPoolDac.GetAllMiningPools(); }