Ejemplo n.º 1
0
 public NeoSystem(ProtocolSettings settings, string storageEngine = null, string storagePath = null)
 {
     this.Settings     = settings;
     this.GenesisBlock = new Block
     {
         Header = new Header
         {
             PrevHash      = UInt256.Zero,
             MerkleRoot    = UInt256.Zero,
             Timestamp     = (new DateTime(2016, 7, 15, 15, 8, 21, DateTimeKind.Utc)).ToTimestampMS(),
             Index         = 0,
             PrimaryIndex  = 0,
             NextConsensus = Contract.GetBFTAddress(settings.StandbyValidators),
             Witness       = new Witness
             {
                 InvocationScript   = Array.Empty <byte>(),
                 VerificationScript = new[] { (byte)OpCode.PUSH1 }
             },
         },
         Transactions = Array.Empty <Transaction>()
     };
     this.storage_engine = storageEngine;
     this.store          = LoadStore(storagePath);
     this.MemPool        = new MemoryPool(this);
     this.Blockchain     = ActorSystem.ActorOf(Ledger.Blockchain.Props(this));
     this.LocalNode      = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this));
     this.TaskManager    = ActorSystem.ActorOf(Network.P2P.TaskManager.Props(this));
     Blockchain.Ask <FillCompleted>(new FillMemoryPool {
         Transactions = Enumerable.Empty <Transaction>()
     }).Wait();
     foreach (var plugin in Plugin.Plugins)
     {
         plugin.OnSystemLoaded(this);
     }
 }
Ejemplo n.º 2
0
 public NeoSystem(ProtocolSettings settings, string storageEngine = null, string storagePath = null)
 {
     this.Settings = settings;
     Plugin.LoadPlugins(this);
     this.storage_engine = storageEngine;
     this.store          = LoadStore(storagePath);
     this.MemPool        = new MemoryPool(this);
     this.Blockchain     = ActorSystem.ActorOf(Ledger.Blockchain.Props(this));
     this.LocalNode      = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this));
     this.TaskManager    = ActorSystem.ActorOf(Network.P2P.TaskManager.Props(this));
     foreach (var plugin in Plugin.Plugins)
     {
         plugin.OnPluginsLoaded();
     }
 }
Ejemplo n.º 3
0
 public NeoSystem(ProtocolSettings settings, string storageEngine = null, string storagePath = null)
 {
     this.Settings       = settings;
     this.GenesisBlock   = CreateGenesisBlock(settings);
     this.storage_engine = storageEngine;
     this.store          = LoadStore(storagePath);
     this.MemPool        = new MemoryPool(this);
     this.Blockchain     = ActorSystem.ActorOf(Ledger.Blockchain.Props(this));
     this.LocalNode      = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this));
     this.TaskManager    = ActorSystem.ActorOf(Network.P2P.TaskManager.Props(this));
     this.TxRouter       = ActorSystem.ActorOf(TransactionRouter.Props(this));
     foreach (var plugin in Plugin.Plugins)
     {
         plugin.OnSystemLoaded(this);
     }
     Blockchain.Ask(new Blockchain.Initialize()).Wait();
 }
Ejemplo n.º 4
0
 public static Block CreateGenesisBlock(ProtocolSettings settings) => new Block
 {
     Header = new Header
     {
         PrevHash      = UInt256.Zero,
         MerkleRoot    = UInt256.Zero,
         Timestamp     = (new DateTime(2016, 7, 15, 15, 8, 21, DateTimeKind.Utc)).ToTimestampMS(),
         Index         = 0,
         PrimaryIndex  = 0,
         NextConsensus = Contract.GetBFTAddress(settings.StandbyValidators),
         Witness       = new Witness
         {
             InvocationScript   = Array.Empty <byte>(),
             VerificationScript = new[] { (byte)OpCode.PUSH1 }
         },
     },
     Transactions = Array.Empty <Transaction>()
 };
Ejemplo n.º 5
0
 public NeoSystem(ProtocolSettings settings, string storageEngine = null, string storagePath = null)
 {
     this.Settings       = settings;
     this.GenesisBlock   = CreateGenesisBlock(settings);
     this.storage_engine = storageEngine;
     this.store          = LoadStore(storagePath);
     this.MemPool        = new MemoryPool(this);
     this.Blockchain     = ActorSystem.ActorOf(Ledger.Blockchain.Props(this));
     this.LocalNode      = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this));
     this.TaskManager    = ActorSystem.ActorOf(Network.P2P.TaskManager.Props(this));
     foreach (var plugin in Plugin.Plugins)
     {
         plugin.OnSystemLoaded(this);
     }
     Blockchain.Ask <FillCompleted>(new FillMemoryPool {
         Transactions = Enumerable.Empty <Transaction>()
     }).Wait();
 }
Ejemplo n.º 6
0
        static ProtocolSettings()
        {
            IConfigurationSection section = new ConfigurationBuilder().AddJsonFile("protocol.json", true).Build().GetSection("ProtocolConfiguration");

            Default = new ProtocolSettings(section);
        }
Ejemplo n.º 7
0
        static bool UpdateDefault(IConfiguration configuration)
        {
            var settings = new ProtocolSettings(configuration.GetSection("ProtocolConfiguration"));

            return(null == Interlocked.CompareExchange(ref _default, settings, null));
        }