-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make calculation for extra gas on "send*" RPC (#70)
* Make calculation for extra gas on "send*" RPC * Fix for the calculation when little overstep
- Loading branch information
1 parent
c611239
commit 0ce4311
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"PluginConfiguration": { | ||
"MaxFee": 0.1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Neo.Plugins | ||
{ | ||
internal class Settings | ||
{ | ||
public Fixed8 MaxFee { get; } | ||
|
||
public static Settings Default { get; private set; } | ||
|
||
private Settings(IConfigurationSection section) | ||
{ | ||
this.MaxFee = GetValueOrDefault(section.GetSection("MaxFee"), Fixed8.FromDecimal(0.1M), p => Fixed8.Parse(p)); | ||
} | ||
|
||
public T GetValueOrDefault<T>(IConfigurationSection section, T defaultValue, Func<string, T> selector) | ||
{ | ||
if (section.Value == null) return defaultValue; | ||
return selector(section.Value); | ||
} | ||
|
||
public static void Load(IConfigurationSection section) | ||
{ | ||
Default = new Settings(section); | ||
} | ||
} | ||
} |