Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static ctor of Network must run before creating other networks #32

Open
ghost opened this issue Aug 6, 2017 · 1 comment
Open

static ctor of Network must run before creating other networks #32

ghost opened this issue Aug 6, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 6, 2017

One cannot run NetworkBuilder.BuildAndRegister() to create a Network before triggering the static ctor of Network one time before so that it already creates BitcoinMain. Otherwise, this line will crash:
assert(consensus.HashGenesisBlock == uint256.Parse("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));

This can be worked around like shown below, but it's very confusing :-)

 
public static void Main(string[] args)
        {
	        var fix= Network.Main; // execute static constructor of Network before everything else, or crash

	        var network = !args.Contains("-testnet") 
				? MyNetworks.RegisterMain() 
				: MyNetworks.RegisterTest();

	        if (NodeSettings.PrintHelp(args, network))
		        return;
@dangershony
Copy link

Whats the problem with the static fields? you can just safely ignore them.

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

No branches or pull requests

1 participant