예제 #1
0
        internal static void LoadPlugins(OXSystem system)
        {
            System = system;
            if (!Directory.Exists(pluginsPath))
            {
                return;
            }
            foreach (string filename in Directory.EnumerateFiles(pluginsPath, "*.dll", SearchOption.TopDirectoryOnly))
            {
                var      file     = File.ReadAllBytes(filename);
                Assembly assembly = Assembly.Load(file);
                foreach (Type type in assembly.ExportedTypes)
                {
                    if (!type.IsSubclassOf(typeof(Plugin)))
                    {
                        continue;
                    }
                    if (type.IsAbstract)
                    {
                        continue;
                    }

                    ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
                    try
                    {
                        constructor?.Invoke(null);
                    }
                    catch (Exception ex)
                    {
                        Log(nameof(Plugin), LogLevel.Error, $"Failed to initialize plugin: {ex.Message}");
                    }
                }
            }
        }
예제 #2
0
 public RpcServer(OXSystem system, Wallet wallet = null, Fixed8 maxGasInvoke = default(Fixed8), int maxConcurrentConnections = Peer.DefaultMaxConnections)
 {
     this.system                   = system;
     this.Wallet                   = wallet;
     this.MaxGasInvoke             = maxGasInvoke;
     this.MaxConcurrentConnections = maxConcurrentConnections;
 }
예제 #3
0
 public RemoteNode(OXSystem system, object connection, IPEndPoint remote, IPEndPoint local)
     : base(connection, remote, local)
 {
     this.system   = system;
     this.protocol = Context.ActorOf(ProtocolHandler.Props(system));
     LocalNode.Singleton.RemoteNodes.TryAdd(Self, this);
     SendMessage(Message.Create("version", VersionPayload.Create(LocalNode.Singleton.ListenerPort, LocalNode.Nonce, LocalNode.UserAgent, Blockchain.Singleton.Height)));
 }
예제 #4
0
 public LocalNode(OXSystem system)
 {
     lock (lockObj)
     {
         if (singleton != null)
         {
             throw new InvalidOperationException();
         }
         this.system = system;
         singleton   = this;
     }
 }
예제 #5
0
 public Blockchain(OXSystem system, Store store)
 {
     this.system  = system;
     this.MemPool = new MemoryPool(system, MemoryPoolMaxTransactions);
     this.Store   = store;
     lock (lockObj)
     {
         if (singleton != null)
         {
             throw new InvalidOperationException();
         }
         header_index.AddRange(store.GetHeaderHashList().Find().OrderBy(p => (uint)p.Key).SelectMany(p => p.Value.Hashes));
         stored_header_count += (uint)header_index.Count;
         if (stored_header_count == 0)
         {
             header_index.AddRange(store.GetBlocks().Find().OrderBy(p => p.Value.TrimmedBlock.Index).Select(p => p.Key));
         }
         else
         {
             HashIndexState hashIndex = store.GetHeaderHashIndex().Get();
             if (hashIndex.Index >= stored_header_count)
             {
                 DataCache <UInt256, BlockState> cache = store.GetBlocks();
                 for (UInt256 hash = hashIndex.Hash; hash != header_index[(int)stored_header_count - 1];)
                 {
                     header_index.Insert((int)stored_header_count, hash);
                     hash = cache[hash].TrimmedBlock.PrevHash;
                 }
             }
         }
         if (header_index.Count == 0)
         {
             Persist(GenesisBlock);
         }
         else
         {
             UpdateCurrentSnapshot();
         }
         singleton = this;
     }
 }
예제 #6
0
 public Coins(Wallet wallet, OXSystem system)
 {
     this.current_wallet = wallet;
     this.system         = system;
 }
예제 #7
0
 public MemoryPool(OXSystem system, int capacity)
 {
     _system  = system;
     Capacity = capacity;
     LoadMaxTxLimitsFromPolicyPlugins();
 }
예제 #8
0
 public static Props Props(OXSystem system)
 {
     return(Akka.Actor.Props.Create(() => new LocalNode(system)));
 }
예제 #9
0
 internal static Props Props(OXSystem system, object connection, IPEndPoint remote, IPEndPoint local)
 {
     return(Akka.Actor.Props.Create(() => new RemoteNode(system, connection, remote, local)).WithMailbox("remote-node-mailbox"));
 }
예제 #10
0
 public static Props Props(OXSystem system, Store store)
 {
     return(Akka.Actor.Props.Create(() => new Blockchain(system, store)).WithMailbox("blockchain-mailbox"));
 }
예제 #11
0
 public TaskManager(OXSystem system)
 {
     this.system = system;
 }
예제 #12
0
 public static Props Props(OXSystem system)
 {
     return(Akka.Actor.Props.Create(() => new TaskManager(system)).WithMailbox("task-manager-mailbox"));
 }