private void Init(INTMinerContext root) { var minerProfileRepository = root.ServerContext.CreateLocalRepository <MinerProfileData>(); _data = minerProfileRepository.GetAll().FirstOrDefault(); var mineWorkRepository = root.ServerContext.CreateLocalRepository <MineWorkData>(); MineWork = mineWorkRepository.GetAll().FirstOrDefault(); if (_data == null) { Guid coinId = Guid.Empty; ICoin coin = root.ServerContext.CoinSet.AsEnumerable().OrderBy(a => a.Code).FirstOrDefault(); if (coin != null) { coinId = coin.GetId(); } _data = MinerProfileData.CreateDefaultData(coinId); } else { // 交换到注册表以供守护进程访问 if (ClientAppType.IsMinerClient && !NTMinerContext.IsJsonLocal) { SetIsOuterUserEnabled(_data.IsOuterUserEnabled); SetOuterUserId(_data.OuterUserId); } } if (_coinProfileSet == null) { _coinProfileSet = new CoinProfileSet(root); } else { _coinProfileSet.Refresh(); } if (_coinKernelProfileSet == null) { _coinKernelProfileSet = new CoinKernelProfileSet(root); } else { _coinKernelProfileSet.Refresh(); } if (_poolProfileSet == null) { _poolProfileSet = new PoolProfileSet(root); } else { _poolProfileSet.Refresh(); } if (_walletSet == null) { _walletSet = new WalletSet(root); } else { _walletSet.Refresh(); } }
private void Init(INTMinerRoot root, MineWorkData mineWorkData) { MineWork = mineWorkData; isUseJson = mineWorkData != null; if (isUseJson) { _data = NTMinerRoot.LocalJson.MinerProfile; } else { IRepository <MinerProfileData> repository = NTMinerRoot.CreateLocalRepository <MinerProfileData>(false); _data = repository.GetAll().FirstOrDefault(); } if (_data == null) { Guid coinId = Guid.Empty; ICoin coin = root.CoinSet.OrderBy(a => a.SortNumber).FirstOrDefault(); if (coin != null) { coinId = coin.GetId(); } _data = MinerProfileData.CreateDefaultData(coinId); } if (_coinProfileSet == null) { _coinProfileSet = new CoinProfileSet(root, mineWorkData); } else { _coinProfileSet.Refresh(mineWorkData); } if (_coinKernelProfileSet == null) { _coinKernelProfileSet = new CoinKernelProfileSet(root, mineWorkData); } else { _coinKernelProfileSet.Refresh(mineWorkData); } if (_poolProfileSet == null) { _poolProfileSet = new PoolProfileSet(root, mineWorkData); } else { _poolProfileSet.Refresh(mineWorkData); } if (_walletSet == null) { _walletSet = new WalletSet(root); } else { _walletSet.Refresh(); } }
private void Init(INTMinerRoot root) { IRepository <MinerProfileData> minerProfileRepository = NTMinerRoot.CreateLocalRepository <MinerProfileData>(); _data = minerProfileRepository.GetAll().FirstOrDefault(); IRepository <MineWorkData> mineWorkRepository = NTMinerRoot.CreateLocalRepository <MineWorkData>(); MineWork = mineWorkRepository.GetAll().FirstOrDefault(); if (_data == null) { Guid coinId = Guid.Empty; ICoin coin = root.CoinSet.OrderBy(a => a.Code).FirstOrDefault(); if (coin != null) { coinId = coin.GetId(); } _data = MinerProfileData.CreateDefaultData(coinId); } if (_coinProfileSet == null) { _coinProfileSet = new CoinProfileSet(root); } else { _coinProfileSet.Refresh(); } if (_coinKernelProfileSet == null) { _coinKernelProfileSet = new CoinKernelProfileSet(root); } else { _coinKernelProfileSet.Refresh(); } if (_poolProfileSet == null) { _poolProfileSet = new PoolProfileSet(root); } else { _poolProfileSet.Refresh(); } if (_walletSet == null) { _walletSet = new WalletSet(root); } else { _walletSet.Refresh(); } }
public string BuildAssembleArgs() { ICoin mainCoin; if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out mainCoin)) { return(string.Empty); } ICoinProfile coinProfile = this.CoinProfileSet.GetCoinProfile(mainCoin.GetId()); IPool mainCoinPool; if (!PoolSet.TryGetPool(coinProfile.PoolId, out mainCoinPool)) { return(string.Empty); } ICoinKernel coinKernel; if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out coinKernel)) { return(string.Empty); } IKernel kernel; if (!KernelSet.TryGetKernel(coinKernel.KernelId, out kernel)) { return(string.Empty); } if (!kernel.IsSupported()) { return(string.Empty); } IKernelInput kernelInput; if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out kernelInput)) { return(string.Empty); } ICoinKernelProfile coinKernelProfile = this.CoinKernelProfileSet.GetCoinKernelProfile(coinProfile.CoinKernelId); string wallet = coinProfile.Wallet; string pool = mainCoinPool.Server; string poolKernelArgs = string.Empty; IPoolKernel poolKernel = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId()); if (poolKernel != null) { poolKernelArgs = poolKernel.Args; } IPoolProfile poolProfile = PoolProfileSet.GetPoolProfile(mainCoinPool.GetId()); string userName = poolProfile.UserName; string password = poolProfile.Password; string kernelArgs = kernelInput.Args; string coinKernelArgs = coinKernel.Args; string customArgs = coinKernelProfile.CustomArgs; var argsDic = new Dictionary <string, string> { { "mainCoin", mainCoin.Code }, { "mainAlgo", mainCoin.Algo }, { "wallet", wallet }, { "userName", userName }, { "password", password }, { "host", mainCoinPool.GetHost() }, { "port", mainCoinPool.GetPort().ToString() }, { "pool", pool }, { "worker", this.MinerProfile.MinerName } };// 这里不要考虑{logfile},{logfile}往后推迟 if (coinKernelProfile.IsDualCoinEnabled) { Guid dualCoinGroupId = coinKernel.DualCoinGroupId; if (dualCoinGroupId == Guid.Empty) { dualCoinGroupId = kernelInput.DualCoinGroupId; } if (dualCoinGroupId != Guid.Empty) { ICoin dualCoin; if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out dualCoin)) { ICoinProfile dualCoinProfile = this.CoinProfileSet.GetCoinProfile(dualCoin.GetId()); IPool dualCoinPool; if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out dualCoinPool)) { string dualWallet = dualCoinProfile.DualCoinWallet; string dualPool = dualCoinPool.Server; IPoolProfile dualPoolProfile = PoolProfileSet.GetPoolProfile(dualCoinPool.GetId()); string dualUserName = dualPoolProfile.UserName; string dualPassword = dualPoolProfile.Password; argsDic.Add("dualCoin", dualCoin.Code); argsDic.Add("dualAlgo", dualCoin.Algo); argsDic.Add("dualWallet", dualWallet); argsDic.Add("dualUserName", dualUserName); argsDic.Add("dualPassword", dualPassword); argsDic.Add("dualHost", dualCoinPool.GetHost()); argsDic.Add("dualPort", dualCoinPool.GetPort().ToString()); argsDic.Add("dualPool", dualPool); kernelArgs = kernelInput.DualFullArgs; AssembleArgs(argsDic, ref kernelArgs, isDual: true); AssembleArgs(argsDic, ref poolKernelArgs, isDual: true); AssembleArgs(argsDic, ref customArgs, isDual: true); string dualWeightArg; if (!string.IsNullOrEmpty(kernelInput.DualWeightArg)) { if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight) { dualWeightArg = string.Empty; } else { dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}"; } } else { dualWeightArg = string.Empty; } return($"{kernelArgs} {dualWeightArg} {poolKernelArgs} {customArgs}"); } } } } AssembleArgs(argsDic, ref kernelArgs, isDual: false); AssembleArgs(argsDic, ref coinKernelArgs, isDual: false); AssembleArgs(argsDic, ref poolKernelArgs, isDual: false); AssembleArgs(argsDic, ref customArgs, isDual: false); return($"{kernelArgs} {coinKernelArgs} {poolKernelArgs} {customArgs}"); }