Skip to content

Commit

Permalink
v2.9.3 (#31)
Browse files Browse the repository at this point in the history
* Update packages reference

* Fix claim (#34)
  • Loading branch information
erikzhang authored Dec 14, 2018
1 parent db04e75 commit 768b885
Show file tree
Hide file tree
Showing 19 changed files with 418 additions and 58 deletions.
4 changes: 2 additions & 2 deletions ApplicationLogs/ApplicationLogs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.9.2</Version>
<Version>2.9.3</Version>
<TargetFrameworks>netstandard2.0;net47</TargetFrameworks>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="2.9.2" />
<PackageReference Include="Neo" Version="2.9.3" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ namespace Neo.Plugins
{
public class LogReader : Plugin, IRpcPlugin
{
private readonly DB db = DB.Open(Path.GetFullPath(Settings.Default.Path), new Options { CreateIfMissing = true });
private readonly DB db;

public override string Name => "ApplicationLogs";

public LogReader()
{
this.db = DB.Open(Path.GetFullPath(Settings.Default.Path), new Options { CreateIfMissing = true });
System.ActorSystem.ActorOf(Logger.Props(System.Blockchain, db));
}

public override void Configure()
{
Settings.Load(GetConfiguration());
}

public JObject OnProcess(HttpContext context, string method, JArray _params)
{
if (method != "getapplicationlog") return null;
Expand Down
11 changes: 5 additions & 6 deletions ApplicationLogs/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
using Microsoft.Extensions.Configuration;
using Neo.Network.P2P;
using System.Reflection;

namespace Neo.Plugins
{
internal class Settings
{
public string Path { get; }

public static Settings Default { get; }
public static Settings Default { get; private set; }

static Settings()
private Settings(IConfigurationSection section)
{
Default = new Settings(Assembly.GetExecutingAssembly().GetConfiguration());
this.Path = string.Format(section.GetSection("Path").Value, Message.Magic.ToString("X8"));
}

public Settings(IConfigurationSection section)
public static void Load(IConfigurationSection section)
{
this.Path = string.Format(section.GetSection("Path").Value, Message.Magic.ToString("X8"));
Default = new Settings(section);
}
}
}
5 changes: 5 additions & 0 deletions ImportBlocks/ImportBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ private static bool CheckMaxOnImportHeight(uint currentImportBlockHeight)
return false;
}

public override void Configure()
{
Settings.Load(GetConfiguration());
}

private static IEnumerable<Block> GetBlocks(Stream stream, bool read_start = false)
{
using (BinaryReader r = new BinaryReader(stream))
Expand Down
4 changes: 2 additions & 2 deletions ImportBlocks/ImportBlocks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.9.2</Version>
<Version>2.9.3</Version>
<TargetFrameworks>netstandard2.0;net47</TargetFrameworks>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="2.9.2" />
<PackageReference Include="Neo" Version="2.9.3" />
</ItemGroup>

</Project>
15 changes: 7 additions & 8 deletions ImportBlocks/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Reflection;

namespace Neo.Plugins
{
internal class Settings
{
public uint MaxOnImportHeight { get; }

public static Settings Default { get; }
public static Settings Default { get; private set; }

static Settings()
{
Default = new Settings(Assembly.GetExecutingAssembly().GetConfiguration());
}

public Settings(IConfigurationSection section)
private Settings(IConfigurationSection section)
{
this.MaxOnImportHeight = GetValueOrDefault(section.GetSection("MaxOnImportHeight"), 0u, p => uint.Parse(p));
}
Expand All @@ -25,5 +19,10 @@ public T GetValueOrDefault<T>(IConfigurationSection section, T defaultValue, Fun
if (section.Value == null) return defaultValue;
return selector(section.Value);
}

public static void Load(IConfigurationSection section)
{
Default = new Settings(section);
}
}
}
5 changes: 5 additions & 0 deletions RpcSecurity/RpcSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace Neo.Plugins
{
public class RpcSecurity : Plugin, IRpcPlugin
{
public override void Configure()
{
Settings.Load(GetConfiguration());
}

public JObject OnProcess(HttpContext context, string method, JArray _params)
{
if (!CheckAuth(context) || Settings.Default.DisabledMethods.Contains(method))
Expand Down
4 changes: 2 additions & 2 deletions RpcSecurity/RpcSecurity.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.9.2</Version>
<Version>2.9.3</Version>
<TargetFrameworks>netstandard2.0;net47</TargetFrameworks>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="2.9.2" />
<PackageReference Include="Neo" Version="2.9.3" />
</ItemGroup>

</Project>
15 changes: 7 additions & 8 deletions RpcSecurity/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Configuration;
using System.Linq;
using System.Reflection;

namespace Neo.Plugins
{
Expand All @@ -10,18 +9,18 @@ internal class Settings
public string RpcPass { get; }
public string[] DisabledMethods { get; }

public static Settings Default { get; }
public static Settings Default { get; private set; }

static Settings()
{
Default = new Settings(Assembly.GetExecutingAssembly().GetConfiguration());
}

public Settings(IConfigurationSection section)
private Settings(IConfigurationSection section)
{
this.RpcUser = section.GetSection("RpcUser").Value;
this.RpcPass = section.GetSection("RpcPass").Value;
this.DisabledMethods = section.GetSection("DisabledMethods").GetChildren().Select(p => p.Value).ToArray();
}

public static void Load(IConfigurationSection section)
{
Default = new Settings(section);
}
}
}
15 changes: 11 additions & 4 deletions SimplePolicy.UnitTests/SimplePolicy.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
<None Update="protocol.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.5.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="Moq" Version="4.7.63" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 768b885

Please sign in to comment.