Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Add MaxConnectionsPerAddress to Settings (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored Apr 5, 2019
1 parent b2ffecf commit 39912ed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions neo-cli/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ internal class P2PSettings
public ushort WsPort { get; }
public int MinDesiredConnections { get; }
public int MaxConnections { get; }
public int MaxConnectionsPerAddress { get; }

public P2PSettings(IConfigurationSection section)
{
this.Port = ushort.Parse(section.GetSection("Port").Value);
this.WsPort = ushort.Parse(section.GetSection("WsPort").Value);
this.MinDesiredConnections = section.GetValue("MinDesiredConnections", Peer.DefaultMinDesiredConnections);
this.MaxConnections = section.GetValue("MaxConnections", Peer.DefaultMaxConnections);
this.MaxConnectionsPerAddress = section.GetValue("MaxConnectionsPerAddress", 3);
}
}

Expand Down
2 changes: 1 addition & 1 deletion neo-cli/Shell/Coins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private Transaction SignTransaction(Transaction tx)

if (context.Completed)
{
context.Verifiable.Witnesses = context.GetWitnesses();
tx.Witnesses = context.GetWitnesses();
current_wallet.ApplyTransaction(tx);

bool relay_result = system.Blockchain.Ask<RelayResultReason>(tx).Result == RelayResultReason.Succeed;
Expand Down
21 changes: 15 additions & 6 deletions neo-cli/Shell/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public bool SignAndSendTx(InvocationTransaction tx)
string msg;
if (context.Completed)
{
context.Verifiable.Witnesses = context.GetWitnesses();
tx.Witnesses = context.GetWitnesses();
Program.Wallet.ApplyTransaction(tx);

system.LocalNode.Tell(new LocalNode.Relay { Inventory = tx });
Expand Down Expand Up @@ -357,10 +357,14 @@ private bool OnRelayCommand(string[] args)
Console.WriteLine("The signature is incomplete.");
return true;
}
context.Verifiable.Witnesses = context.GetWitnesses();
IInventory inventory = (IInventory)context.Verifiable;
system.LocalNode.Tell(new LocalNode.Relay { Inventory = inventory });
Console.WriteLine($"Data relay success, the hash is shown as follows:\r\n{inventory.Hash}");
if (!(context.Verifiable is Transaction tx))
{
Console.WriteLine($"Only support to relay transaction.");
return true;
}
tx.Witnesses = context.GetWitnesses();
system.LocalNode.Tell(new LocalNode.Relay { Inventory = tx });
Console.WriteLine($"Data relay success, the hash is shown as follows:\r\n{tx.Hash}");
}
catch (Exception e)
{
Expand Down Expand Up @@ -1187,7 +1191,12 @@ protected internal override void OnStart(string[] args)
}
store = new LevelDBStore(Path.GetFullPath(Settings.Default.Paths.Chain));
system = new NeoSystem(store);
system.StartNode(Settings.Default.P2P.Port, Settings.Default.P2P.WsPort, Settings.Default.P2P.MinDesiredConnections, Settings.Default.P2P.MaxConnections);
system.StartNode(
port: Settings.Default.P2P.Port,
wsPort: Settings.Default.P2P.WsPort,
minDesiredConnections: Settings.Default.P2P.MinDesiredConnections,
maxConnections: Settings.Default.P2P.MaxConnections,
maxConnectionsPerAddress: Settings.Default.P2P.MaxConnectionsPerAddress);
if (Settings.Default.UnlockWallet.IsActive)
{
try
Expand Down
2 changes: 1 addition & 1 deletion neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="2.10.0" />
<PackageReference Include="Neo" Version="2.10.1" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.5.0" />
</ItemGroup>

Expand Down

0 comments on commit 39912ed

Please sign in to comment.