public LibplanetNodeService( LibplanetNodeServiceProperties <T> properties, IBlockPolicy <T> blockPolicy, Func <BlockChain <T>, Swarm <T>, PrivateKey, CancellationToken, Task> minerLoopAction, Progress <PreloadState> preloadProgress, bool ignoreBootstrapFailure = false ) { _properties = properties; var genesisBlock = LoadGenesisBlock(properties); var iceServers = _properties.IceServers; Store = LoadStore( _properties.StorePath, _properties.StoreType, _properties.StoreStatesCacheSize); var chainIds = Store.ListChainIds().ToList(); Log.Debug($"Number of chain ids: {chainIds.Count()}"); foreach (var chainId in chainIds) { Log.Debug($"chainId: {chainId}"); } BlockChain = new BlockChain <T>(blockPolicy, Store, genesisBlock, _properties.Render); _minerLoopAction = minerLoopAction; Swarm = new Swarm <T>( BlockChain, _properties.PrivateKey, _properties.AppProtocolVersion, trustedAppProtocolVersionSigners: _properties.TrustedAppProtocolVersionSigners, host: _properties.Host, listenPort: _properties.Port, iceServers: iceServers, workers: 50, differentAppProtocolVersionEncountered: _properties.DifferentAppProtocolVersionEncountered ); PreloadEnded = new AsyncManualResetEvent(); BootstrapEnded = new AsyncManualResetEvent(); _preloadProgress = preloadProgress; _ignoreBootstrapFailure = ignoreBootstrapFailure; }
private Block <T> LoadGenesisBlock(LibplanetNodeServiceProperties <T> properties) { if (!(properties.GenesisBlock is null)) { return(properties.GenesisBlock); }