Esempio n. 1
0
        public ServerJsonDb(INTMinerRoot root, LocalJsonDb localJsonObj)
        {
            var minerProfile    = root.MinerProfile;
            var mainCoinProfile = minerProfile.GetCoinProfile(minerProfile.CoinId);

            root.CoinKernelSet.TryGetCoinKernel(mainCoinProfile.CoinKernelId, out ICoinKernel coinKernel);
            root.KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel);
            var coins      = root.CoinSet.Cast <CoinData>().Where(a => localJsonObj.CoinProfiles.Any(b => b.CoinId == a.Id)).ToArray();
            var coinGroups = root.CoinGroupSet.Cast <CoinGroupData>().Where(a => coins.Any(b => b.Id == a.CoinId)).ToArray();
            var pools      = root.PoolSet.Cast <PoolData>().Where(a => localJsonObj.PoolProfiles.Any(b => b.PoolId == a.Id)).ToArray();

            Coins                   = coins;
            CoinGroups              = coinGroups;
            Pools                   = pools;
            Groups                  = root.GroupSet.Cast <GroupData>().Where(a => coinGroups.Any(b => b.GroupId == a.Id)).ToArray();
            KernelInputs            = root.KernelInputSet.Cast <KernelInputData>().Where(a => a.Id == kernel.KernelInputId).ToArray();
            KernelOutputs           = root.KernelOutputSet.Cast <KernelOutputData>().Where(a => a.Id == kernel.KernelOutputId).ToArray();
            KernelOutputFilters     = root.KernelOutputFilterSet.Cast <KernelOutputFilterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray();
            KernelOutputTranslaters = root.KernelOutputTranslaterSet.Cast <KernelOutputTranslaterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray();
            Kernels                 = new List <KernelData> {
                (KernelData)kernel
            };
            CoinKernels = root.CoinKernelSet.Cast <CoinKernelData>().Where(a => localJsonObj.CoinKernelProfiles.Any(b => b.CoinKernelId == a.Id)).ToList();
            PoolKernels = root.PoolKernelSet.Cast <PoolKernelData>().Where(a => !string.IsNullOrEmpty(a.Args) && pools.Any(b => b.Id == a.PoolId)).ToList();
            SysDicItems = root.SysDicItemSet.Cast <SysDicItemData>().ToArray();
            SysDics     = root.SysDicSet.Cast <SysDicData>().ToArray();
            TimeStamp   = Timestamp.GetTimestamp();
        }
Esempio n. 2
0
        public ServerJsonDb(INTMinerContext ntminerContext, LocalJsonDb localJsonObj) : this()
        {
            var minerProfile    = ntminerContext.MinerProfile;
            var mainCoinProfile = minerProfile.GetCoinProfile(minerProfile.CoinId);

            ntminerContext.ServerContext.CoinKernelSet.TryGetCoinKernel(mainCoinProfile.CoinKernelId, out ICoinKernel coinKernel);
            if (coinKernel == null)
            {
                return;
            }
            ntminerContext.ServerContext.KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel);
            if (kernel == null)
            {
                return;
            }
            var coins      = ntminerContext.ServerContext.CoinSet.AsEnumerable().Cast <CoinData>().Where(a => localJsonObj.CoinProfiles.Any(b => b.CoinId == a.Id)).ToArray();
            var coinGroups = ntminerContext.ServerContext.CoinGroupSet.AsEnumerable().Cast <CoinGroupData>().Where(a => coins.Any(b => b.Id == a.CoinId)).ToArray();
            var pools      = ntminerContext.ServerContext.PoolSet.AsEnumerable().Cast <PoolData>().Where(a => localJsonObj.PoolProfiles.Any(b => b.PoolId == a.Id)).ToList();

            Coins = coins;
            // json向后兼容
            foreach (var coin in Coins)
            {
                if (ntminerContext.ServerContext.SysDicItemSet.TryGetDicItem(coin.AlgoId, out ISysDicItem dicItem))
                {
                    coin.Algo = dicItem.Value;
                }
            }
            CoinGroups              = coinGroups;
            Pools                   = pools;
            Groups                  = ntminerContext.ServerContext.GroupSet.AsEnumerable().Cast <GroupData>().Where(a => coinGroups.Any(b => b.GroupId == a.Id)).ToArray();
            KernelInputs            = ntminerContext.ServerContext.KernelInputSet.AsEnumerable().Cast <KernelInputData>().Where(a => a.Id == kernel.KernelInputId).ToArray();
            KernelOutputs           = ntminerContext.ServerContext.KernelOutputSet.AsEnumerable().Cast <KernelOutputData>().Where(a => a.Id == kernel.KernelOutputId).ToArray();
            KernelOutputTranslaters = ntminerContext.ServerContext.KernelOutputTranslaterSet.AsEnumerable().Cast <KernelOutputTranslaterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray();
            Kernels                 = new List <KernelData> {
                (KernelData)kernel
            };
            Packages        = ntminerContext.ServerContext.PackageSet.AsEnumerable().Cast <PackageData>().Where(a => a.Name == kernel.Package).ToList();
            CoinKernels     = ntminerContext.ServerContext.CoinKernelSet.AsEnumerable().Cast <CoinKernelData>().Where(a => localJsonObj.CoinKernelProfiles.Any(b => b.CoinKernelId == a.Id)).ToList();
            FileWriters     = ntminerContext.ServerContext.FileWriterSet.AsEnumerable().Cast <FileWriterData>().ToList();         // 这个数据没几条就不精简了
            FragmentWriters = ntminerContext.ServerContext.FragmentWriterSet.AsEnumerable().Cast <FragmentWriterData>().ToList(); // 这个数据没几条就不精简了
            PoolKernels     = ntminerContext.ServerContext.PoolKernelSet.AsEnumerable().Cast <PoolKernelData>().Where(a => !string.IsNullOrEmpty(a.Args) && pools.Any(b => b.Id == a.PoolId)).ToList();
            SysDicItems     = ntminerContext.ServerContext.SysDicItemSet.AsEnumerable().Cast <SysDicItemData>().ToArray();
            SysDics         = ntminerContext.ServerContext.SysDicSet.AsEnumerable().Cast <SysDicData>().ToArray();
            TimeStamp       = NTMinerContext.ServerJsonDb.TimeStamp;
        }
Esempio n. 3
0
        public ServerJsonDb(INTMinerRoot root, LocalJsonDb localJsonObj)
        {
            var minerProfile    = root.MinerProfile;
            var mainCoinProfile = minerProfile.GetCoinProfile(minerProfile.CoinId);

            root.CoinKernelSet.TryGetCoinKernel(mainCoinProfile.CoinKernelId, out ICoinKernel coinKernel);
            root.KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel);
            var coins      = root.CoinSet.Cast <CoinData>().Where(a => localJsonObj.CoinProfiles.Any(b => b.CoinId == a.Id)).ToArray();
            var coinGroups = root.CoinGroupSet.Cast <CoinGroupData>().Where(a => coins.Any(b => b.Id == a.CoinId)).ToArray();
            var pools      = root.PoolSet.Cast <PoolData>().Where(a => localJsonObj.PoolProfiles.Any(b => b.PoolId == a.Id)).ToList();

            Coins = coins;
            // json向后兼容
            foreach (var coin in Coins)
            {
                if (root.SysDicItemSet.TryGetDicItem(coin.AlgoId, out ISysDicItem dicItem))
                {
                    coin.Algo = dicItem.Value;
                }
            }
            CoinGroups              = coinGroups;
            Pools                   = pools;
            Groups                  = root.GroupSet.Cast <GroupData>().Where(a => coinGroups.Any(b => b.GroupId == a.Id)).ToArray();
            KernelInputs            = root.KernelInputSet.Cast <KernelInputData>().Where(a => a.Id == kernel.KernelInputId).ToArray();
            KernelOutputs           = root.KernelOutputSet.Cast <KernelOutputData>().Where(a => a.Id == kernel.KernelOutputId).ToArray();
            KernelOutputFilters     = root.KernelOutputFilterSet.Cast <KernelOutputFilterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray();
            KernelOutputTranslaters = root.KernelOutputTranslaterSet.Cast <KernelOutputTranslaterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray();
            Kernels                 = new List <KernelData> {
                (KernelData)kernel
            };
            Packages    = root.PackageSet.Cast <PackageData>().Where(a => a.Name == kernel.Package).ToList();
            CoinKernels = root.CoinKernelSet.Cast <CoinKernelData>().Where(a => localJsonObj.CoinKernelProfiles.Any(b => b.CoinKernelId == a.Id)).ToList();
            PoolKernels = root.PoolKernelSet.Cast <PoolKernelData>().Where(a => !string.IsNullOrEmpty(a.Args) && pools.Any(b => b.Id == a.PoolId)).ToList();
            SysDicItems = root.SysDicItemSet.Cast <SysDicItemData>().ToArray();
            SysDics     = root.SysDicSet.Cast <SysDicData>().ToArray();
            TimeStamp   = NTMinerRoot.ServerJson.TimeStamp;
        }