Ejemplo n.º 1
0
        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
            });
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public static BlockchainSettings FromNative(Knuth.Native.Config.BlockchainSettings native)
        {
            var res = new BlockchainSettings();

            res.Cores                 = native.cores;
            res.Priority              = native.priority;
            res.ByteFeeSatoshis       = native.byte_fee_satoshis;
            res.SigopFeeSatoshis      = native.sigop_fee_satoshis;
            res.MinimumOutputSatoshis = native.minimum_output_satoshis;
            res.NotifyLimitHours      = native.notify_limit_hours;
            res.ReorganizationLimit   = native.reorganization_limit;
            res.Checkpoints           = Helper.ArrayOfPointersToManaged <Checkpoint, Native.Config.Checkpoint>(native.checkpoints, native.checkpoint_count, Checkpoint.FromNative);
            res.FixCheckpoints        = native.fix_checkpoints;
            res.AllowCollisions       = native.allow_collisions;
            res.EasyBlocks            = native.easy_blocks;
            res.Retarget              = native.retarget;
            res.Bip16                 = native.bip16;
            res.Bip30                 = native.bip30;
            res.Bip34                 = native.bip34;
            res.Bip66                 = native.bip66;
            res.Bip65                 = native.bip65;
            res.Bip90                 = native.bip90;
            res.Bip68                 = native.bip68;
            res.Bip112                = native.bip112;
            res.Bip113                = native.bip113;

#if KTH_CS_CURRENCY_BCH        //TODO(fernando): rename to CURRENCY_BCH or something like that
            res.BchUahf             = native.bch_uahf;
            res.BchDaaCw144         = native.bch_daa_cw144;
            res.BchPythagoras       = native.bch_pythagoras;
            res.BchEuclid           = native.bch_euclid;
            res.BchPisano           = native.bch_pisano;
            res.BchMersenne         = native.bch_mersenne;
            res.BchFermat           = native.bch_fermat;
            res.BchEuler            = native.bch_euler;
            res.BchGauss            = native.bch_gauss;
            res.EulerActivationTime = native.euler_activation_time;
            res.GaussActivationTime = native.gauss_activation_time;
            res.AsertHalfLife       = native.asert_half_life;
#else
            res.Bip141 = native.bip141;
            res.Bip141 = native.bip141;
            res.Bip147 = native.bip147;
#endif //KTH_CS_CURRENCY_BCH
            return(res);
        }