Skip to content

Commit

Permalink
xdc-0.8.3g
Browse files Browse the repository at this point in the history
- pause sync if activity or storage queues have more than 2000 items (out of memory exception fix during sync)
- removed /sync API
  • Loading branch information
IxiAngel committed Jan 6, 2022
1 parent e226633 commit ef47821
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
15 changes: 0 additions & 15 deletions IxianDLT/API/APIServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ protected override bool processRequest(HttpListenerContext context, string metho
{
JsonResponse response = null;

if (methodName.Equals("sync", StringComparison.OrdinalIgnoreCase))
{
response = onSync();
}

if (methodName.Equals("getbalance", StringComparison.OrdinalIgnoreCase))
{
response = onGetBalance(parameters);
Expand Down Expand Up @@ -176,16 +171,6 @@ protected override bool processRequest(HttpListenerContext context, string metho
return true;
}


public JsonResponse onSync()
{
JsonError error = null;

Node.synchronize();

return new JsonResponse { result = "Synchronizing to network now.", error = error };
}

private Dictionary<string, string> blockToJsonDictionary(Block block)
{
Dictionary<string, string> blockData = new Dictionary<string, string>();
Expand Down
6 changes: 4 additions & 2 deletions IxianDLT/Block/BlockSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class BlockSync
private long lastProcessedBlockTime = 0;

private List<Block> lastBlocks = new List<Block>();

public bool paused = false;
public BlockSync()
{
synchronizing = false;
Expand All @@ -84,7 +86,7 @@ public void rollForwardLoop()
while (running)
{
TLC.Report();
if (synchronizing == false || syncDone == true)
if (paused || synchronizing == false || syncDone == true)
{
Thread.Sleep(1000);
continue;
Expand Down Expand Up @@ -123,7 +125,7 @@ public void fetchLoop()
while (running)
{
TLC.Report();
if (synchronizing == false || syncDone == true)
if (paused || synchronizing == false || syncDone == true)
{
Thread.Sleep(1000);
continue;
Expand Down
2 changes: 1 addition & 1 deletion IxianDLT/Meta/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static string dataFolderBlocks
public static ulong forceSyncToBlock = 0;

// Read-only values
public static readonly string version = "xdc-0.8.3f"; // DLT Node version
public static readonly string version = "xdc-0.8.3g"; // DLT Node version

public static readonly string checkVersionUrl = "https://www.ixian.io/update.txt";
public static readonly int checkVersionSeconds = 6 * 60 * 60; // 6 hours
Expand Down
33 changes: 14 additions & 19 deletions IxianDLT/Meta/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,25 +601,6 @@ static public void stop()
NetDump.Instance.shutdown();
}

static public void synchronize()
{
// Clear everything and force a resynchronization
Logging.info("\n\n\tSynchronizing to network...\n");

blockProcessor.stopOperation();

blockProcessor = new BlockProcessor();
blockChain = new BlockChain();
walletState.clear();
TransactionPool.clear();

NetworkQueue.stop();
NetworkQueue.start();

// Finally, reconnect to the network
CoreNetworkUtils.reconnect();
}

// Checks to see if this node can handle the block number
static public bool checkCurrentBlockDeprecation(ulong block)
{
Expand Down Expand Up @@ -805,6 +786,20 @@ private static void performMaintenance()

// Remove expired peers from blacklist
PeerStorage.updateBlacklist();

if(blockSync.synchronizing)
{
int storageQueueCount = storage.getQueuedQueryCount();
int activityQueueCount = ActivityStorage.getQueuedQueryCount();
if (storageQueueCount > 2000 || activityQueueCount > 2000)
{
blockSync.paused = true;
}
else if (storageQueueCount < 1000 && activityQueueCount < 1000)
{
blockSync.paused = false;
}
}
}
catch (Exception e)
{
Expand Down

0 comments on commit ef47821

Please sign in to comment.