public static uint CalculateMinGasEstimate(this WonkaEthEngineProps poEngineProps, uint pnWriteOpGasCost = CONST_GAS_PER_WRITE_OP) { uint nMinGasCost = 50000; if ((poEngineProps.RulesEngine != null) && (poEngineProps.RulesEngine.RuleTreeRoot != null)) { nMinGasCost = poEngineProps.RulesEngine.CalculateMinGasEstimate(pnWriteOpGasCost); } return(nMinGasCost); }
public static uint CalculateMinGasEstimate(this WonkaEthEngineProps poEngineProps, uint pnWriteOpGasCost = CONST_GAS_PER_WRITE_OP) { uint nMinGasCost = 50000; if ((poEngineProps.RulesEngine != null) && (poEngineProps.RulesEngine.RuleTreeRoot != null)) { // NOTE: Do work here // 63200 gas per op, based on gas default price // 12 ops for Validate, 18 ops Calculate if (poEngineProps.RulesEngine.RuleTreeRoot.ChildRuleSets != null) { poEngineProps.RulesEngine.RuleTreeRoot.ChildRuleSets.ForEach(x => nMinGasCost += (uint)(x.EvaluativeRules.Count * CONST_GAS_PER_READ_OP)); poEngineProps.RulesEngine.RuleTreeRoot.ChildRuleSets.ForEach(x => nMinGasCost += (uint)(x.AssertiveRules.Count * pnWriteOpGasCost)); } } return(nMinGasCost); }
public static uint CalculateMaxGasEstimate(this WonkaEthEngineProps poEngineProps, uint pnWriteOpGasCost = CONST_GAS_PER_WRITE_OP) { uint nMaxGasCost = 50000; if ((poEngineProps.RulesEngine != null) && (poEngineProps.RulesEngine.RuleTreeRoot != null)) { // NOTE: Do work here // 63200 gas per op, based on gas default price // 12 ops for Validate, 18 ops Calculate if (poEngineProps.RulesEngine.RuleTreeRoot.ChildRuleSets != null) { poEngineProps.RulesEngine.RuleTreeRoot.ChildRuleSets.ForEach(x => nMaxGasCost += (uint)(x.EvaluativeRules.Count * CONST_GAS_PER_READ_OP)); poEngineProps.RulesEngine.RuleTreeRoot.ChildRuleSets.ForEach(x => nMaxGasCost += (uint)(x.AssertiveRules.Count * pnWriteOpGasCost)); } if (poEngineProps.RulesEngine.AllRuleSets != null) { poEngineProps.RulesEngine.AllRuleSets.ForEach(x => nMaxGasCost += (uint)(x.EvaluativeRules.Count * CONST_GAS_PER_READ_OP)); foreach (WonkaBre.RuleTree.WonkaBreRuleSet TempRuleSet in poEngineProps.RulesEngine.AllRuleSets) { foreach (WonkaBre.RuleTree.WonkaBreRule TempRule in TempRuleSet.AssertiveRules) { if (TempRule.RuleType == RULE_TYPE.RT_CUSTOM_OP) { nMaxGasCost += (uint)(3 * pnWriteOpGasCost); } else { nMaxGasCost += (uint)(pnWriteOpGasCost); } } } } } return(nMaxGasCost); }