Skip to content

Commit

Permalink
Allows the wallet to be opened after the RpcServer constructor is run.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Oct 23, 2018
1 parent fcc3c31 commit dbe688b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
20 changes: 10 additions & 10 deletions neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ namespace Neo
{
public class NeoSystem : IDisposable
{
public readonly ActorSystem ActorSystem = ActorSystem.Create(nameof(NeoSystem),
public ActorSystem ActorSystem { get; } = ActorSystem.Create(nameof(NeoSystem),
$"akka {{ log-dead-letters = off }}" +
$"blockchain-mailbox {{ mailbox-type: \"{typeof(BlockchainMailbox).AssemblyQualifiedName}\" }}" +
$"task-manager-mailbox {{ mailbox-type: \"{typeof(TaskManagerMailbox).AssemblyQualifiedName}\" }}" +
$"remote-node-mailbox {{ mailbox-type: \"{typeof(RemoteNodeMailbox).AssemblyQualifiedName}\" }}" +
$"protocol-handler-mailbox {{ mailbox-type: \"{typeof(ProtocolHandlerMailbox).AssemblyQualifiedName}\" }}" +
$"consensus-service-mailbox {{ mailbox-type: \"{typeof(ConsensusServiceMailbox).AssemblyQualifiedName}\" }}");
public readonly IActorRef Blockchain;
public readonly IActorRef LocalNode;
internal readonly IActorRef TaskManager;
internal IActorRef Consensus;
private RpcServer rpcServer;
public IActorRef Blockchain { get; }
public IActorRef LocalNode { get; }
internal IActorRef TaskManager { get; }
public IActorRef Consensus { get; private set; }
public RpcServer RpcServer { get; private set; }

public NeoSystem(Store store)
{
Expand All @@ -36,7 +36,7 @@ public NeoSystem(Store store)

public void Dispose()
{
rpcServer?.Dispose();
RpcServer?.Dispose();
ActorSystem.Stop(LocalNode);
ActorSystem.Dispose();
}
Expand All @@ -56,11 +56,11 @@ public void StartNode(int port = 0, int ws_port = 0)
});
}

public void StartRpc(IPAddress bindAddress, int port, Wallet wallet = null, string sslCert = null, string password = null,
public void StartRpc(IPAddress bindAddress, int port, Wallet wallet = null, string sslCert = null, string password = null,
string[] trustedAuthorities = null, Fixed8 maxGasInvoke = default(Fixed8))
{
rpcServer = new RpcServer(this, wallet, maxGasInvoke);
rpcServer.Start(bindAddress, port, sslCert, password, trustedAuthorities);
RpcServer = new RpcServer(this, wallet, maxGasInvoke);
RpcServer.Start(bindAddress, port, sslCert, password, trustedAuthorities);
}
}
}
7 changes: 6 additions & 1 deletion neo/Network/RPC/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Neo.Network.RPC
public sealed class RpcServer : IDisposable
{
private readonly NeoSystem system;
private readonly Wallet wallet;
private Wallet wallet;
private IWebHost host;
private Fixed8 maxGasInvoke;

Expand Down Expand Up @@ -131,6 +131,11 @@ private static JObject GetRelayResult(RelayResultReason reason)
}
}

public void OpenWallet(Wallet wallet)
{
this.wallet = wallet;
}

private JObject Process(string method, JArray _params)
{
switch (method)
Expand Down

0 comments on commit dbe688b

Please sign in to comment.