Beispiel #1
0
        public MemoryBlockchain(Block? genesisBlock = null)
        {
            this.shutdownToken = new CancellationToken();
            this.random = new Random();

            // create the key pair that block rewards will be sent to
            var keyPair = TransactionManager.CreateKeyPair();
            this._coinbasePrivateKey = keyPair.Item1;
            this._coinbasePublicKey = keyPair.Item2;

            // initialize unit test storage
            this._storageContext = new MemoryStorageContext();
            this._cacheContext = new CacheContext(this._storageContext);

            // initialize unit test rules
            this._rules = new UnitTestRules(this._cacheContext);

            // initialize blockchain calculator
            this._calculator = new BlockchainCalculator(this._rules, this._cacheContext, this.shutdownToken);

            // create and mine the genesis block
            this._genesisBlock = genesisBlock ?? MineEmptyBlock(0);

            // update genesis blockchain and add to storage
            this._rules.SetGenesisBlock(this._genesisBlock);
            this._currentBlockchain = this._rules.GenesisBlockchain;
            this._genesisChainedBlock = AddBlock(this._genesisBlock, null).Item2;
        }
        public static void Main(string[] args)
        {
            //TODO
            //MainnetRules.BypassValidation = true;
            //MainnetRules.BypassExecuteScript = true;
            ScriptEngine.BypassVerifySignature = true;

            using (var storageContext = new MemoryStorageContext())
            using (var cacheContext = new CacheContext(storageContext))
            {
                var rules = new Testnet2Rules(cacheContext);

                using (var blockchainDaemon = new BlockchainDaemon(rules, cacheContext))
                using (var knownAddressStorage = new MemoryStorage<NetworkAddressKey, NetworkAddressWithTime>(storageContext))
                using (var localClient = new LocalClient(LocalClientType.ComparisonToolTestNet, blockchainDaemon, knownAddressStorage))
                {
                    // start the blockchain daemon
                    blockchainDaemon.Start();

                    // start p2p client
                    localClient.Start();

                    var projectFolder = Environment.CurrentDirectory;
                    while (projectFolder.Contains(@"\bin"))
                        projectFolder = Path.GetDirectoryName(projectFolder);

                    File.Delete(Path.Combine(projectFolder, "Bitcoinj-comparison.log"));

                    var javaProcessStartInfo = new ProcessStartInfo
                        {
                            FileName = @"C:\Program Files\Java\jdk1.7.0_25\bin\java.exe",
                            WorkingDirectory = projectFolder,
                            Arguments = @"-Djava.util.logging.config.file={0}\bitcoinj.log.properties -jar {0}\bitcoinj.jar".Format2(projectFolder),
                            UseShellExecute = false
                        };

                    var javaProcess = Process.Start(javaProcessStartInfo);

                    javaProcess.WaitForExit((int)TimeSpan.FromMinutes(5).TotalMilliseconds);
                    Console.ReadLine();
                }
            }
        }
Beispiel #3
0
 public MemoryStorage(MemoryStorageContext storageContext)
 {
     this._storageContext = storageContext;
 }
 public MemoryBlockchainStorage(MemoryStorageContext storageContext)
 {
     this._storageContext = storageContext;
 }
Beispiel #5
0
 public MemoryBlockHeaderStorage(MemoryStorageContext storageContext)
     : base(storageContext)
 {
 }
Beispiel #6
0
 public MemoryChainedBlockStorage(MemoryStorageContext storageContext)
     : base(storageContext)
 {
 }
 public MemoryBlockchainStorage(MemoryStorageContext storageContext)
 {
     this._storageContext = storageContext;
 }
Beispiel #8
0
 public MemoryBlockTransactionsStorage(MemoryStorageContext storageContext)
     : base(storageContext)
 {
 }