public static ApiCallResultWithMessage <Settings> GetFromFile(string path) { string errorMessage; IntPtr nativePtr; // Console.WriteLine("C# GetFromFile path: {0}", path); var ok = Knuth.Native.Config.SettingsNative.kth_config_settings_get_from_file(path, out nativePtr, out errorMessage); if (!ok) { return(new ApiCallResultWithMessage <Settings> { Ok = false, ErrorMessage = errorMessage, Result = null }); } var native = (Native.Config.Settings)Marshal.PtrToStructure(nativePtr, typeof(Native.Config.Settings)); var res = new Settings(); res.Chain = BlockchainSettings.FromNative(native.chain); res.Database = DatabaseSettings.FromNative(native.database); res.Network = NetworkSettings.FromNative(native.network); res.Node = NodeSettings.FromNative(native.node); Knuth.Native.Config.SettingsNative.kth_config_settings_destruct(nativePtr); return(new ApiCallResultWithMessage <Settings> { Ok = true, ErrorMessage = null, Result = res }); }
public static Settings GetDefault(NetworkType network) { var res = new Settings(); res.Chain = BlockchainSettings.GetDefault(network); res.Database = DatabaseSettings.GetDefault(network); res.Network = NetworkSettings.GetDefault(network); res.Node = NodeSettings.GetDefault(network); return(res); }
public static Settings GetDefault(NetworkType network) { var res = new Settings(); res.Chain = BlockchainSettings.GetDefault(network); res.Database = DatabaseSettings.GetDefault(network); res.Network = NetworkSettings.GetDefault(network); res.Node = NodeSettings.GetDefault(network); //TODO(fernando): remove this in c-api version > 0.6.0. It is a workaround. res.Network.Services = 1; res.Network.HostPoolCapacity = 1000; return(res); }
public static NetworkSettings FromNative(Knuth.Native.Config.NetworkSettings native) { var res = new NetworkSettings(); res.Threads = native.threads; res.ProtocolMaximum = native.protocol_maximum; res.ProtocolMinimum = native.protocol_minimum; res.Services = native.services; res.InvalidServices = native.invalid_services; res.RelayTransactions = native.relay_transactions; res.ValidateChecksum = native.validate_checksum; res.Identifier = native.identifier; res.InboundPort = native.inbound_port; res.InboundConnections = native.inbound_connections; res.OutboundConnections = native.outbound_connections; res.ManualAttemptLimit = native.manual_attempt_limit; res.ConnectBatchSize = native.connect_batch_size; res.ConnectTimeoutSeconds = native.connect_timeout_seconds; res.ChannelHandshakeSeconds = native.channel_handshake_seconds; res.ChannelHeartbeatMinutes = native.channel_heartbeat_minutes; res.ChannelInactivityMinutes = native.channel_inactivity_minutes; res.ChannelExpirationMinutes = native.channel_expiration_minutes; res.ChannelGerminationSeconds = native.channel_germination_seconds; res.HostPoolCapacity = native.host_pool_capacity; // res.HostsFile = Helper.PtrToString(native.hosts_file); res.HostsFile = native.hosts_file; res.Self = Authority.FromNative(native.self); res.Blacklist = Helper.ArrayOfPointersToManaged <Authority, Native.Config.Authority>(native.blacklists, native.blacklist_count, Authority.FromNative); res.Peers = Helper.ArrayOfPointersToManaged <Endpoint, Native.Config.Endpoint>(native.peers, native.peer_count, Endpoint.FromNative); res.Seeds = Helper.ArrayOfPointersToManaged <Endpoint, Native.Config.Endpoint>(native.seeds, native.seed_count, Endpoint.FromNative); // res.DebugFile = Helper.PtrToString(native.debug_file); // res.ErrorFile = Helper.PtrToString(native.error_file); // res.ArchiveDirectory = Helper.PtrToString(native.archive_directory); res.DebugFile = native.debug_file; res.ErrorFile = native.error_file; res.ArchiveDirectory = native.archive_directory; res.RotationSize = native.rotation_size; res.MinimumFreeSpace = native.minimum_free_space; res.MaximumArchiveSize = native.maximum_archive_size; res.MaximumArchiveFiles = native.maximum_archive_files; res.StatisticsServer = Authority.FromNative(native.statistics_server); res.Verbose = native.verbose; res.UseIpV6 = native.use_ipv6; res.UserAgentBlacklist = Helper.ArrayOfStringsToManaged(native.user_agent_blacklist, native.user_agent_blacklist_count); return(res); }