Skip to content
This repository has been archived by the owner on May 23, 2021. It is now read-only.

Add ForkWatchJob #4

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Add ForkWatchJob #4

wants to merge 9 commits into from

Conversation

h4x3rotab
Copy link

This PR adds a job to watch chain fork

Copy link
Owner

@Vutov Vutov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few comments. In addition the example app.settings needs to be updated with the new property and the documentation needs update for the new job with short summary what it does.


class VirtualCheckpoint
{
public int Height;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use property, not field for DTOs. And convention follows to end with DTO in the name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

class VirtualCheckpoint
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to separate .cs file

public string Hash;
}

class WatchJobExecutor
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to separate .cs file , seems like Service, And convention follows to end with Service in the name.


public void Execute()
{
rpcConfig = JobCommon.GetRpcConfig(config);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config can be injected into the method and gathered inside of the job.

if (shouldSend)
{
shouldBacktrace = true;
var url = ""; // TODO: upload to pastbin and get url
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Active TODO


if (tips == null || tips.Length == 0)
{
logger.LogWarning("ForkWatch: Got bad tip");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add additional information, bad tip is not descriptive enough to determine a potential problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return;
}

// check virtual checkpoint rolled-back
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should explain why something is done, not how or what. Comment convention uses upper first letter.

var message = $"ForkWatch: Virtual checkpoint {lastCheckpoint.Hash} at height {lastCheckpoint.Height} replaced by {hash}";
notificationManager.TriggerHook(message);
});
// TODO: if foundReorg, move to "PREPARE"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Active TODO

using Microsoft.Extensions.Configuration;
using System.Net;

public class JobCommon {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move as method inside of Job. Each job inherits that class.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants