Skip to content

Commit

Permalink
Add start command
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Jan 13, 2021
1 parent 8f941d5 commit 82e1571
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI01148" />
<PackageReference Include="Neo" Version="3.0.0-CI01152" />
</ItemGroup>

</Project>
12 changes: 11 additions & 1 deletion src/dBFT/DBFTPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Akka.Actor;
using Neo.ConsoleService;
using Neo.Network.P2P;
using Neo.Plugins;
using Neo.Wallets;
Expand All @@ -8,14 +9,23 @@ namespace Neo.Consensus
public class DBFTPlugin : Plugin, IConsensusProvider, IP2PPlugin
{
private IActorRef consensus;
private bool started = false;

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

void IConsensusProvider.Start(Wallet wallet)
[ConsoleCommand("start consensus", Category = "Consensus", Description = "Start consensus service (dBFT)")]
private void OnStart()
{
Start(GetService<IWalletProvider>().GetWallet());
}

public void Start(Wallet wallet)
{
if (started) return;
started = true;
consensus = System.ActorSystem.ActorOf(ConsensusService.Props(System.LocalNode, System.TaskManager, System.Blockchain, System.LoadStore(Settings.Default.RecoveryLogs), wallet));
consensus.Tell(new ConsensusService.Start());
}
Expand Down
4 changes: 4 additions & 0 deletions src/dBFT/dBFT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<RootNamespace>Neo.Consensus</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo.ConsoleService" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<None Update="dBFT\config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down

0 comments on commit 82e1571

Please sign in to comment.