예제 #1
0
        // Initializes an empty block
        internal Block(BlockchainCache Blockchain)
        {
            // Set blockchain reference
            this.Blockchain = Blockchain;

            // Setup defaults
            Height          = 0;
            Timestamp       = 0;
            Nonce           = 0;
            MajorVersion    = Constants.BLOCK_MAJOR_VERSION_1;
            MinorVersion    = Constants.BLOCK_MINOR_VERSION;
            BaseReward      = 0;
            TotalFees       = 0;
            BaseTransaction = new Transaction();
            Transactions    = new Transaction[0];
        }
예제 #2
0
        /// <summary>
        /// Initializes this node with the specified network configuration
        /// </summary>
        /// <param name="Configuration">A class containing all global information this node needs to operate</param>
        public Node(NodeConfig Configuration)
        {
            // Assign configuration
            Globals = Configuration;

            // Generate identifier
            Id = SecureRandom.Integer <ulong>();

            // Setup and start logger
            Logger = new Logger()
            {
                LogFile        = Globals.LOG_FILE,
                LogLevel       = Globals.LOG_LEVEL,
                CustomPrefix   = Globals.CUSTOM_PREFIX,
                ImportantColor = Globals.IMPORTANT_COLOR,
                InfoColor      = Globals.INFO_COLOR,
                ErrorColor     = Globals.ERROR_COLOR,
                WarningColor   = Globals.WARNING_COLOR,
                DebugColor     = Globals.DEBUG_COLOR
            };

            // Setup blockchain cache
            Blockchain = new BlockchainCache()
            {
                Logger = Logger
            };

            // Create our P2P server
            P2pServer = new P2pServer(Globals.P2P_WORKERS, Globals.P2P_MAX_PEER_CONNECTIONS)
            {
                ConnectionTimeout = Globals.P2P_CONNECTION_TIMEOUT
            };

            // Setup our API server
            ApiServer = new ApiServer(Globals.API_WORKERS, Globals.API_PASSWORD)
            {
                Logger = Logger
            };

            // Setup done, set node to stopped
            Stopped = true;
        }
예제 #3
0
        // Initializes a block using a base transaction
        internal Block(BlockchainCache Blockchain, string Hex)
        {
            // Set blockchain reference
            this.Blockchain = Blockchain;

            // Setup defaults
            Height          = 0;
            Timestamp       = 0;
            Nonce           = 0;
            MajorVersion    = Constants.BLOCK_MAJOR_VERSION_1;
            MinorVersion    = Constants.BLOCK_MINOR_VERSION;
            BaseReward      = 0;
            TotalFees       = 0;
            BaseTransaction = new Transaction();
            Transactions    = new Transaction[0];

            // TODO - deserialize from hex

            // TODO - parent block shit
            ParentBlock = new Block(Blockchain);
        }