private void DistributeGas(ApplicationEngine engine, UInt160 account, NeoAccountState state) { BigInteger gas = CalculateBonus(engine.Snapshot, state.Balance, state.BalanceHeight, engine.Snapshot.PersistingBlock.Index); state.BalanceHeight = engine.Snapshot.PersistingBlock.Index; GAS.Mint(engine, account, gas); }
internal override async ContractTask PostPersist(ApplicationEngine engine) { // Distribute GAS for committee int m = engine.ProtocolSettings.CommitteeMembersCount; int n = engine.ProtocolSettings.ValidatorsCount; int index = (int)(engine.PersistingBlock.Index % (uint)m); var gasPerBlock = GetGasPerBlock(engine.Snapshot); var committee = GetCommitteeFromCache(engine.Snapshot); var pubkey = committee[index].PublicKey; var account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash(); await GAS.Mint(engine, account, gasPerBlock *CommitteeRewardRatio / 100, false); // Record the cumulative reward of the voters of committee if (ShouldRefreshCommittee(engine.PersistingBlock.Index, m)) { BigInteger voterRewardOfEachCommittee = gasPerBlock * VoterRewardRatio * 100000000L * m / (m + n) / 100; // Zoom in 100000000 times, and the final calculation should be divided 100000000L for (index = 0; index < committee.Count; index++) { var member = committee[index]; var factor = index < n ? 2 : 1; // The `voter` rewards of validator will double than other committee's if (member.Votes > 0) { BigInteger voterSumRewardPerNEO = factor * voterRewardOfEachCommittee / member.Votes; StorageKey voterRewardKey = CreateStorageKey(Prefix_VoterRewardPerCommittee).Add(member.PublicKey).AddBigEndian(engine.PersistingBlock.Index + 1); byte[] border = CreateStorageKey(Prefix_VoterRewardPerCommittee).Add(member.PublicKey).ToArray(); (_, var item) = engine.Snapshot.FindRange(voterRewardKey.ToArray(), border, SeekDirection.Backward).FirstOrDefault(); voterSumRewardPerNEO += (item ?? BigInteger.Zero); engine.Snapshot.Add(voterRewardKey, new StorageItem(voterSumRewardPerNEO)); } } } }
public int CompareTo(object obj) { clsTeam t = (clsTeam)obj; int ret = Points.CompareTo(t.Points); if (ret == 0) { ret = Wins.CompareTo(t.Wins); } if (ret == 0) { ret = aRecord[t.Number - 1]; } if (ret == 0) { ret = GAS.CompareTo(t.GAS); } if (ret == 0) { ret = (-1) * GA.CompareTo(t.GA); } return(ret); }
private void DistributeGas(ApplicationEngine engine, UInt160 account, AccountState state) { BigInteger gas = CalculateBonus(engine.Snapshot, state.Balance, state.BalanceHeight, engine.Snapshot.PersistingBlock.Index); state.BalanceHeight = engine.Snapshot.PersistingBlock.Index; GAS.Mint(engine, account, gas); engine.Snapshot.Storages.GetAndChange(CreateAccountKey(account)).Value = state.ToByteArray(); }
private protected override async ContractTask PostTransfer(ApplicationEngine engine, UInt160 from, UInt160 to, BigInteger amount, StackItem data, bool callOnPayment) { await base.PostTransfer(engine, from, to, amount, data, callOnPayment); var list = engine.CurrentContext.GetState <List <GasDistribution> >(); foreach (var distribution in list) { await GAS.Mint(engine, distribution.Account, distribution.Amount, callOnPayment); } }
private void DistributeGas(ApplicationEngine engine, UInt160 account, NeoAccountState state) { // PersistingBlock is null when running under the debugger if (engine.Snapshot.PersistingBlock == null) { return; } BigInteger gas = CalculateBonus(engine.Snapshot, state.Balance, state.BalanceHeight, engine.Snapshot.PersistingBlock.Index); state.BalanceHeight = engine.Snapshot.PersistingBlock.Index; GAS.Mint(engine, account, gas); }
protected override void PostPersist(ApplicationEngine engine) { base.PostPersist(engine); // Distribute GAS for committee int index = (int)(engine.Snapshot.PersistingBlock.Index % (uint)ProtocolSettings.Default.CommitteeMembersCount); var gasPerBlock = GetGasPerBlock(engine.Snapshot); var pubkey = GetCommittee(engine.Snapshot)[index]; var account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash(); GAS.Mint(engine, account, gasPerBlock * CommitteeRewardRatio / 100); }
private async ContractTask DistributeGas(ApplicationEngine engine, UInt160 account, NeoAccountState state) { // PersistingBlock is null when running under the debugger if (engine.PersistingBlock is null) { return; } BigInteger gas = CalculateBonus(engine.Snapshot, state.VoteTo, state.Balance, state.BalanceHeight, engine.PersistingBlock.Index); state.BalanceHeight = engine.PersistingBlock.Index; await GAS.Mint(engine, account, gas, true); }
//[{"type":"Hash160","value":"0xf621168b1fce3a89c33a5f6bcf7e774b4657031c"}] public static void GasCall(UInt160 account) { OnNotify(account); OnNotify(GAS.Name); OnNotify(GAS.Symbol); OnNotify(GAS.Decimals); OnNotify(GAS.TotalSupply()); OnNotify(GAS.BalanceOf(account)); OnNotify(GAS.Transfer((UInt160)account, Owner, 1000)); OnNotify(Owner); }
//[{"type":"Hash160","value":"0xf621168b1fce3a89c33a5f6bcf7e774b4657031c"}] public static void GasCall(UInt160 account) { OnNotify(account); OnNotify(GAS.Hash); OnNotify(GAS.Symbol); OnNotify(GAS.Decimals); OnNotify(GAS.TotalSupply()); OnNotify(GAS.BalanceOf(account)); OnNotify(GAS.Transfer((UInt160)account, Owner, 123456789, null)); OnNotify(Owner); }
private BigInteger CalculateBonus(Snapshot snapshot, BigInteger value, uint start, uint end) { if (value.IsZero || start >= end) { return(BigInteger.Zero); } if (value.Sign < 0) { throw new ArgumentOutOfRangeException(nameof(value)); } BigInteger amount = BigInteger.Zero; uint ustart = start / Blockchain.DecrementInterval; if (ustart < Blockchain.GenerationAmount.Length) { uint istart = start % Blockchain.DecrementInterval; uint uend = end / Blockchain.DecrementInterval; uint iend = end % Blockchain.DecrementInterval; if (uend >= Blockchain.GenerationAmount.Length) { uend = (uint)Blockchain.GenerationAmount.Length; iend = 0; } if (iend == 0) { uend--; iend = Blockchain.DecrementInterval; } while (ustart < uend) { amount += (Blockchain.DecrementInterval - istart) * Blockchain.GenerationAmount[ustart]; ustart++; istart = 0; } amount += (iend - istart) * Blockchain.GenerationAmount[ustart]; } amount += (GAS.GetSysFeeAmount(snapshot, end - 1) - (start == 0 ? 0 : GAS.GetSysFeeAmount(snapshot, start - 1))) / GAS.Factor; return(value * amount * GAS.Factor / TotalAmount); }
/// <summary> 将Eclipse数模文件转换成SimON数模文件 </summary> public SimONData ConvertToSimON(EclipseData ecl) { // Todo :Eclipse里面的修改参数没有解析成SimON中修改参数 ecl.RunModify(); RUNSPEC runspec = ecl.Key.Find <RUNSPEC>(); GRID grid = ecl.Key.Find <GRID>(); SOLUTION solution = ecl.Key.Find <SOLUTION>(); SUMMARY summary = ecl.Key.Find <SUMMARY>(); SCHEDULE schedule = ecl.Key.Find <SCHEDULE>(); REGIONS regions = ecl.Key.Find <REGIONS>(); PROPS props = ecl.Key.Find <PROPS>(); SimONData simon = new SimONData(); simon.FileName = ecl.FileName; simon.FilePath = ecl.FilePath; simon.MmfDirPath = ecl.MmfDirPath; simon.InitConstruct(); simon.X = ecl.X; simon.Y = ecl.Y; simon.Z = ecl.Z; // 模型定义 #region - 起始时间 - SOLVECTRL tuning = new SOLVECTRL("TUNING"); tuning.Date = ecl.Key.Find <START>().StartTime; simon.Key.Add(tuning); #endregion #region - 维数定义 - RSVSIZE rsvsize = new RSVSIZE("RSVSIZE"); DIMENS dimens = ecl.Key.Find <DIMENS>(); rsvsize.X = dimens.X; rsvsize.Y = dimens.Y; rsvsize.Z = dimens.Z; simon.Key.Add(rsvsize); #endregion #region - 单位类型 - UnitType unitType = UnitType.METRIC; // 读到METRIC公制单位 METRIC metric = ecl.Key.Find <METRIC>(); if (metric != null) { simon.Key.Add(metric); unitType = UnitType.METRIC; } // 单位类型 FIELD field = ecl.Key.Find <FIELD>(); if (field != null) { simon.Key.Add(field); unitType = UnitType.FIELD; } #endregion #region - 流体类型 - MODELTYPE modeltype = new MODELTYPE("MODELTYPE"); // 流体类型 OIL oil = runspec.Find <OIL>(); WATER water = runspec.Find <WATER>(); GAS gas = runspec.Find <GAS>(); DISGAS disgas = runspec.Find <DISGAS>(); VAPOIL vapoil = runspec.Find <VAPOIL>(); // 黑油 if (oil != null && water != null && gas != null && disgas != null && vapoil == null) { modeltype.MetricType = MetricType.BLACKOIL; } // 油水 else if (oil != null && water != null && gas == null && disgas == null && vapoil == null) { modeltype.MetricType = MetricType.OILWATER; } // 气水 else if (oil == null && water != null && gas != null && disgas == null && vapoil == null) { modeltype.MetricType = MetricType.GASWATER; } // 挥发油 else if (oil != null && water != null && gas != null && disgas != null && vapoil != null) { modeltype.MetricType = MetricType.HFOIL; } else { modeltype.MetricType = MetricType.BLACKOIL; } simon.Key.Add(modeltype); #endregion #region - 分区维数 - EQUILREG equilreg = new EQUILREG("EQUILREG"); FIPREG fipreg = new FIPREG("FIPREG"); ROCKREG rockreg = new ROCKREG("ROCKREG"); SATREG satreg = new SATREG("SATREG"); PVTREG pvtreg = new PVTREG("PVTREG"); simon.Key.Add(equilreg); simon.Key.Add(fipreg); simon.Key.Add(rockreg); simon.Key.Add(satreg); simon.Key.Add(pvtreg); TABDIMS tabdims = runspec.Find <TABDIMS>(); if (tabdims != null) { fipreg.X = tabdims.Fipfqzds4.ToString(); rockreg.X = tabdims.Yslxgs12.ToString(); satreg.X = tabdims.Bhdbs0.ToString(); pvtreg.X = tabdims.Pvtbs1.ToString(); //fipreg.X = "1"; //rockreg.X = "1"; //satreg.X = "1"; //pvtreg.X = "1"; } EQLDIMS eqldims = runspec.Find <EQLDIMS>(); if (eqldims != null) { //equilreg.X = "1"; equilreg.X = eqldims.Phfqs0.ToString(); } OVERBURD overburd = props.Find <OVERBURD>(); if (overburd != null) { //rockreg.X = overburd.Regions.Count.ToString(); } EQUILMAP equilmap = new EQUILMAP("EQUILMAP"); FIPMAP fipmap = new FIPMAP("FIPMAP"); ROCKMAP rockmap = new ROCKMAP("ROCKMAP"); SATMAP satmap = new SATMAP("SATMAP"); PVTMAP pvtmap = new PVTMAP("PVTMAP"); if (regions != null) { EQLNUM eqlnum = regions.Find <EQLNUM>(); if (eqlnum != null) { equilmap = eqlnum.ToTableKey <EQUILMAP>(); solution.Add(equilmap); eqlnum.Delete(); eqlnum.Dispose(); } // Todo :非平衡初始化压力需要转换 var pressure = solution.Find <PRESSURE>(); if (pressure != null) { POIL poil = pressure.ToTableKey <POIL>(); solution.Add(poil); pressure.Delete(); pressure.Dispose(); } if (regions != null) { FIPNUM fipnum = regions.Find <FIPNUM>(); if (fipnum != null) { fipmap = fipnum.ToTableKey <FIPMAP>(); grid.Add(fipmap); fipnum.Delete(); fipnum.Dispose(); } ROCKNUM rocknum = regions.Find <ROCKNUM>(); if (rocknum != null) { rockmap = rocknum.TransToTableKeyByName("ROCKMAP", true) as ROCKMAP; grid.Add(rockmap); rocknum.Delete(); rocknum.Dispose(); } SATNUM satnum = regions.Find <SATNUM>(); if (satnum != null) { satmap = satnum.ToTableKey <SATMAP>(); grid.Add(satmap); satnum.Delete(); satnum.Dispose(); } PVTNUM pvtnum = regions.Find <PVTNUM>(); if (pvtnum != null) { pvtmap = pvtnum.ToTableKey <PVTMAP>(); grid.Add(pvtmap); pvtnum.Delete(); pvtnum.Dispose(); } } } #endregion #region - 地质模型 - simon.Key.Add(grid); #endregion #region - 断层 - //var eclFaults = grid.FindAll<OPT.Product.SimalorManager.RegisterKeys.Eclipse.FAULTS>(); //foreach (var v in eclFaults) //{ //grid.AddRange(this.ConvertToSimON(v)); //v.Delete(); //} #endregion #region - 水体 - //AQUFETP AQUFETP= // Todo :Fetkovich水体数据转换 var ct = solution.Find <OPT.Product.SimalorManager.RegisterKeys.Eclipse.AQUCT>(); if (ct != null) { var newFetp = this.ConvertToSimON(ct); solution.Add(newFetp); ct.Delete(); } // Todo :Fetkovich水体数据转换 var fetp = solution.Find <OPT.Product.SimalorManager.RegisterKeys.Eclipse.AQUFETP>(); if (fetp != null) { var newFetp = this.ConvertToSimON(fetp); solution.Add(newFetp); fetp.Delete(); } // Todo :水体连接数据转换 var aquancon = solution.Find <OPT.Product.SimalorManager.RegisterKeys.Eclipse.AQUANCON>(); if (aquancon != null) { var newFetp = this.ConvertToSimON(aquancon); solution.Add(newFetp); aquancon.Delete(); } #endregion #region - 流体模型 岩石模型- GRAVITY gravity = ecl.Key.Find <GRAVITY>(); if (gravity != null) { // Todo :SimON只解析绝对密度 DENSITY density = this.ConvertTo(gravity, unitType); gravity.ParentKey.Add(density); gravity.Delete(); } List <IRegionInterface> regSoltionKeys = solution.FindAll <IRegionInterface>(); regSoltionKeys.ForEach(l => l.TransToSimONRegion()); simon.Key.Add(solution); // List <IRegionInterface> regPropsKeys = props.FindAll <IRegionInterface>(); regPropsKeys.ForEach(l => l.TransToSimONRegion()); //// Todo :SGWFN 需要特殊转换为 SWGF //SGWFN sgwfn = props.Find<SGWFN>(); //if (sgwfn != null) //{ // //props.AddRange(sgwfn.ConvertTo()); // simon.Key.AddRange<SWGF>(sgwfn.ConvertTo()); //} simon.Key.Add(props); #endregion #region - 初始化模型 - List <EQUIL> equil = solution.FindAll <EQUIL>(); foreach (var item in equil) { EQUILPAR equilpar = new EQUILPAR("EQUILPAR"); EQUIL.Item it = item.GetSingleRegion().GetSingleItem(); equilpar.Szstzdhs0 = it.cksd0; equilpar.Szstljs1 = it.ckyl1; equilpar.Ctstyxhs2 = it.ysjmsd2; equilpar.Ctstyxzdhs3 = it.ysjmcmgyl3.ToDefalt("0"); //equilpar.Jxstzds4 = it.yqjmsd4; equilpar.E100wgzds5 = it.yqjmsd4; equilpar.E300jxstzds6 = it.yqjmcmgyl5; item.ParentKey.Add(equilpar); item.Delete(); } #endregion #region - 生产模型 - WELL well = new WELL("WELL"); // Todo :添加完井数据 (注意要放到生产模型前面) simon.Key.Add(well); // 生产模型 simon.Key.Add(this.ConvertToSimON(schedule, well, ecl.Key.Find <START>().StartTime, simon.HistoryData)); #endregion // Todo :转换修正关键字 List <ModifyKey> modifys = ecl.Key.FindAll <ModifyKey>(); grid.AddRange(modifys); return(simon); }
public ToonStats() { ht = new HT(); mf = new MF(); nego = new Nego(); traya = new Traya(); en = new EN(); padme = new Padme(); jkr = new JKR(); grievous = new Grievous(); bsf = new BSF(); bossk = new Bossk(); gba = new GBA(); mal = new Malevolence(); dr = new DR(); dm = new DM(); gas = new GAS(); rey = new Rey(); slkr = new SLKR(); }
public static void ReceiveGas(UInt160 address, BigInteger amount) { Assert(Runtime.CheckWitness(GetAdmin()), "Forbidden"); GAS.Transfer(Runtime.ExecutingScriptHash, address, amount); }