Skip to content

Commit

Permalink
Merge branch 'testnet' into testnet-coreclr
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Zhang committed Oct 15, 2016
2 parents 05a6242 + b4d6c40 commit ed35261
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
11 changes: 11 additions & 0 deletions AntSharesCore/Network/LocalNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,17 @@ public RemoteNode[] GetRemoteNodes()
}
}

public static Transaction GetTransaction(UInt256 hash)
{
lock (MemoryPool)
{
Transaction tx;
if (!MemoryPool.TryGetValue(hash, out tx))
return null;
return tx;
}
}

private static bool IsIntranetAddress(IPAddress address)
{
byte[] data = address.MapToIPv4().GetAddressBytes();
Expand Down
2 changes: 2 additions & 0 deletions AntSharesCore/Network/RemoteNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ private void OnGetDataMessageReceived(InvPayload payload)
switch (vector.Type)
{
case InventoryType.TX:
if (inventory == null)
inventory = LocalNode.GetTransaction(hash);
if (inventory == null && Blockchain.Default != null)
inventory = Blockchain.Default.GetTransaction(vector.Hash);
if (inventory != null)
Expand Down
4 changes: 3 additions & 1 deletion AntSharesDaemon/Network/RPC/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ private JObject InternalCall(string method, JArray _params)
{
UInt256 hash = UInt256.Parse(_params[0].AsString());
bool verbose = _params.Count >= 2 && _params[1].AsBooleanOrDefault(false);
Transaction tx = Blockchain.Default.GetTransaction(hash);
Transaction tx = LocalNode.GetTransaction(hash);
if (tx == null)
tx = Blockchain.Default.GetTransaction(hash);
if (tx == null)
throw new RpcException(-101, "Unknown transaction");
if (verbose)
Expand Down
13 changes: 9 additions & 4 deletions Miner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace AntShares
{
static class Program
{
private static readonly object LogSync = new object();

// private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
// {
//#if DEBUG
Expand Down Expand Up @@ -34,10 +36,13 @@ internal static void Log(string message)
DateTime now = DateTime.Now;
string line = $"[{now.TimeOfDay:hh\\:mm\\:ss}] {message}";
Console.WriteLine(line);
string path = Path.Combine(AppContext.BaseDirectory, "Logs");
Directory.CreateDirectory(path);
path = Path.Combine(path, $"{now:yyyy-MM-dd}.log");
File.AppendAllLines(path, new[] { line });
lock (LogSync)
{
string path = Path.Combine(AppContext.BaseDirectory, "Logs");
Directory.CreateDirectory(path);
path = Path.Combine(path, $"{now:yyyy-MM-dd}.log");
File.AppendAllLines(path, new[] { line });
}
}

static void Main(string[] args)
Expand Down

0 comments on commit ed35261

Please sign in to comment.