コード例 #1
1
        /// <summary>
        /// Creates a new miner instance.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="extraNonce"></param>
        /// <param name="connection"></param>
        /// <param name="pool"></param>
        /// <param name="minerManager"></param>
        /// <param name="storageLayer"></param>
        public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager, IStorageLayer storageLayer)
        {
            Id = id; // the id of the miner.
            ExtraNonce = extraNonce;
            Connection = connection; // the underlying connection.
            Pool = pool;
            _minerManager = minerManager;
            _storageLayer = storageLayer;

            Subscribed = false; // miner has to subscribe.
            Authenticated = false; // miner has to authenticate.

            _logger = Log.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
            _packetLogger = LogManager.PacketLogger.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);

            _rpcResultHandler = callback =>
            {
                var asyncData = ((JsonRpcStateAsync)callback); // get the async data.
                var result = asyncData.Result + "\n"; // read the result.
                var response = Encoding.UTF8.GetBytes(result); // set the response.

                Connection.Send(response); // send the response.

                _packetLogger.Verbose("tx: {0}", result.PrettifyJson());
            };
        }
コード例 #2
0
 public AsyncStreamSocketSession(Socket client, SslProtocols security, IPool<BufferState> bufferStatePool, bool isReset)
     : base(client)
 {
     SecureProtocol = security;
     m_BufferStatePool = bufferStatePool;
     m_IsReset = isReset;
 }
コード例 #3
0
		public void Setup()
		{
			b = new Binding ();
			b.ToPool ();

			binding = (b as IPool);
		}
コード例 #4
0
        public override bool Start()
        {
            try
            {
                var config = AppServer.Config;
                int bufferSize = config.ReceiveBufferSize;

                if (bufferSize <= 0)
                    bufferSize = 1024 * 4;

                m_BufferManager = AppServer.BufferManager;

                var initialCount = Math.Min(Math.Max(config.MaxConnectionNumber / 15, 100), config.MaxConnectionNumber);
                m_SaePool = new IntelliPool<SocketAsyncEventArgs>(initialCount, new SaeCreator(m_BufferManager, bufferSize));

                if (!base.Start())
                    return false;

                IsRunning = true;
                return true;
            }
            catch (Exception e)
            {
                AppServer.Logger.Error(e);
                return false;
            }
        }
コード例 #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="pool"></param>
        /// <param name="minerManager"></param>
        public GetworkMiner(int id, IPool pool, IMinerManager minerManager)
        {
            Id = id; // the id of the miner.
            Pool = pool;
            _minerManager = minerManager;

            Authenticated = false; // miner has to authenticate.

            Software = MinerSoftware.Unknown;
            SoftwareVersion = new Version();

            _logger = Log.ForContext<GetworkMiner>().ForContext("Component", pool.Config.Coin.Name);
            _packetLogger = LogManager.PacketLogger.ForContext<GetworkMiner>().ForContext("Component", pool.Config.Coin.Name);

            _rpcResultHandler = callback =>
            {
                var asyncData = ((JsonRpcStateAsync) callback);
                var result = asyncData.Result;
                var response = Encoding.UTF8.GetBytes(result);
                var context = (GetworkContext) asyncData.AsyncState;

                context.Response.ContentType = "application/json";
                context.Response.ContentEncoding = Encoding.UTF8;
                context.Response.ContentLength64 = response.Length;
                context.Response.OutputStream.Write(response, 0, response.Length);

                _packetLogger.Verbose("tx: {0}", result.PrettifyJson());
            };
        }
コード例 #6
0
 public VanillaServer(IPool pool, IMinerManager minerManager, IJobManager jobManager, ICoinConfig coinConfig)
 {
     _pool = pool;
     _minerManager = minerManager;
     _jobManager = jobManager;
     _logger = Log.ForContext<VanillaServer>().ForContext("Component", coinConfig.Name);
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StratumServer"/> class.
 /// </summary>
 /// <param name="pool"></param>
 /// <param name="minerManager">The miner manager.</param>
 /// <param name="jobManager"></param>
 /// <param name="banManager"></param>
 /// <param name="poolConfig"></param>
 public StratumServer(IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager, IBanManager banManager)
 {
     _pool = pool;
     _minerManager = minerManager;
     _jobManager = jobManager;
     _banManager = banManager;
     _logger = Log.ForContext<StratumServer>().ForContext("Component", poolConfig.Coin.Name);
 }
コード例 #8
0
 public UdpAsyncServer(int port,int maxThread,int bufferSize)
 {
     receives = new List<SocketAsyncEventArgs>(maxThread);
     this.maxThread = maxThread;
     this.port = port;
     this.bufferSize = bufferSize;
     sendArgsPool = new EventArgsPool(1000, bufferSize, SendCompleted);
 }
コード例 #9
0
ファイル: UdpServer.cs プロジェクト: luohuazhiyu/sunsocket
 public UdpServer(UdpConfig config, ILoger loger)
 {
     this.Config = config;
     this.Loger = loger;
     sendArgsPool = new EventArgsPool(config.MaxSendEventArgs);
     receiveEventArgsList = new List<SocketAsyncEventArgs>(config.ListenerThreads);
     BufferPool = new FixedBufferPool(config.MaxFixedBufferPoolSize, config.BufferSize);
 }
コード例 #10
0
 /// <summary>
 /// Gets the specified service name.
 /// </summary>
 /// <param name="serverName">Name of the service.</param>
 /// <param name="pool"></param>
 /// <param name="minerManager">The miner manager.</param>
 /// <returns></returns>
 public IMiningServer Get(string serverName, IPool pool, IMinerManager minerManager, IJobManager jobManager)
 {
     var @params = new NamedParameterOverloads
     {
         {"pool", pool},
         {"minerManager", minerManager},
         {"jobManager", jobManager}
     };
     return _applicationContext.Container.Resolve<IMiningServer>(serverName, @params);
 }
コード例 #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="pool"></param>
        /// <param name="minerManager"></param>
        /// <param name="logManager"></param>
        public VanillaMiner(int id, IPool pool, IMinerManager minerManager)
        {
            Id = id; // the id of the miner.
            Pool = pool;
            _minerManager = minerManager;

            Authenticated = false; // miner has to authenticate.

            _logger = LogManager.PacketLogger.ForContext<VanillaMiner>().ForContext("Component", pool.Config.Coin.Name);
        }
コード例 #12
0
        /// <summary>
        /// Creates a new miner instance.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="extraNonce"></param>
        /// <param name="connection"></param>
        /// <param name="pool"></param>
        /// <param name="minerManager"></param>
        public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager)
        {
            Id = id; // the id of the miner.
            ExtraNonce = extraNonce;
            Connection = connection; // the underlying connection.
            _minerManager = minerManager;
            Pool = pool;
            Difficulty = new Difficulty(16); // set miner difficulty.

            Subscribed = false; // miner has to subscribe.
            Authenticated = false; // miner has to authenticate.
            SupportsJobNotifications = true; // stratum miner'ssupports new mining job notifications.
        }
コード例 #13
0
        /// <summary>
        /// Creates a new miner instance.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="extraNonce"></param>
        /// <param name="connection"></param>
        /// <param name="pool"></param>
        /// <param name="minerManager"></param>
        /// <param name="logManager"></param>
        public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager)
        {
            Id = id; // the id of the miner.
            ExtraNonce = extraNonce;
            Connection = connection; // the underlying connection.
            _minerManager = minerManager;
            Pool = pool;

            Difficulty = 16; // set miner difficulty.

            Subscribed = false; // miner has to subscribe.
            Authenticated = false; // miner has to authenticate.

            _logger = LogManager.PacketLogger.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
        }
コード例 #14
0
		public override object Resolve(CreationContext context)
		{
			if (pool == null)
			{
				lock (ComponentActivator)
				{
					if (pool == null)
					{
						pool = CreatePool(initialSize, maxSize);
					}
				}
			}

			return pool.Request(context);
		}
コード例 #15
0
		protected override object CreateInstance(CreationContext context, Burden burden)
		{
			if (pool == null)
			{
				lock (ComponentActivator)
				{
					if (pool == null)
					{
						pool = CreatePool(initialSize, maxSize);
					}
				}
			}

			var instance = pool.Request(context);
			burden.SetRootInstance(instance);
			return instance;
		}
コード例 #16
0
        public IMiningServer GetMiningServer(string type, IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager, IBanManager banManager)
        {
            var @params = new NamedParameterOverloads
            {
                {"poolConfig", poolConfig},
                {"pool", pool},
                {"minerManager", minerManager},
                {"jobManager", jobManager},
                {"banManager", banManager},
            };

            return _applicationContext.Container.Resolve<IMiningServer>(type, @params);
        }
コード例 #17
0
ファイル: RoutedEventData.cs プロジェクト: RUSshy/ultraviolet
 /// <summary>
 /// Allocates the object for use.
 /// </summary>
 /// <param name="origin">The pool which originated the object.</param>
 /// <param name="source">The object that raised the event.</param>
 /// <param name="handled">A value indicating whether the event has been handled.</param>
 /// <param name="autorelease">A value indicating whether the data is automatically released
 /// back to the global pool after it has been used by an event handler delegate.</param>
 protected virtual void OnRetrieved(IPool origin, DependencyObject source, Boolean handled, Boolean autorelease)
 {
     this.originalSource = source;
     this.source = source;
     this.handled = handled;
     this.autorelease = autorelease;
     this.origin = origin;
 }
コード例 #18
0
ファイル: Pool.cs プロジェクト: BeauPrime/BeauPools
 /// <summary>
 /// Enables using IDisposable.Dispose when an element is disposed/destroyed.
 /// </summary>
 static public void UseIDisposable <T>(this IPool <T> inPool) where T : class, IDisposable
 {
     inPool.Config.RegisterOnDestruct(IDisposableOnDispose <T>);
 }
コード例 #19
0
ファイル: Pool.cs プロジェクト: BeauPrime/BeauPools
        /// <summary>
        /// Returns a temporary allocation.
        /// </summary>
        static public TempAlloc <T> TempAlloc <T>(this IPool <T> inThis) where T : class
        {
            T obj = inThis.Alloc();

            return(new TempAlloc <T>(inThis, obj));
        }
コード例 #20
0
 public void Init(IPool pool)
 {
 }
コード例 #21
0
ファイル: PoolItem.cs プロジェクト: jamesburton/AndEngine.net
 //public bool isFromPool(final Pool<? extends PoolItem> pPool) {
 public bool IsFromPool(/* final */ IPool pPool)
 {
     return pPool == this.mParent;
 }
コード例 #22
0
 public UdpSocketListener(ListenerInfo info, IPool<SaeState> saePool)
     : base(info)
 {
     m_SaePool = saePool;
 }
コード例 #23
0
ファイル: GetworkServer.cs プロジェクト: meritlabs/merit-pool
 public GetworkServer(IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager)
 {
     _pool         = pool;
     _minerManager = minerManager;
     _logger       = Log.ForContext <GetworkServer>().ForContext("Component", poolConfig.Coin.Name);
 }
コード例 #24
0
 public PoolElementUsageHandler(IPool <TElement> pool, TElement element)
 {
     _used    = false;
     _pool    = pool;
     _element = element;
 }
コード例 #25
0
 void IClientPoolable.OnInstanceCreated(Pool pool)
 {
     _pool = pool;
     _go   = gameObject;
 }
コード例 #26
0
 public AutoReturnTakeTokens(IPool tokensToTake)
 {
     m_TokensToTake = tokensToTake
                      ?? throw new ArgumentNullException(nameof(tokensToTake));
 }
コード例 #27
0
 public UdpSocketListener(ListenerInfo info, IPool <SaeState> saePool)
     : base(info)
 {
     m_SaePool = saePool;
 }
コード例 #28
0
 public AsyncStreamSocketSession(Socket client, SslProtocols security, IPool <BufferState> bufferStatePool)
     : this(client, security, bufferStatePool, false)
 {
 }
コード例 #29
0
 public PooledFactory(IPool <T> pool)
 {
     this.pool = pool ?? throw new ArgumentNullException();
 }
コード例 #30
0
 public AsyncSocketSession(Socket client, IPool<SocketAsyncEventArgs> saePoolForReceive, bool isReset)
     : base(client)
 {
     m_SaePoolForReceive = saePoolForReceive;
     m_IsReset = isReset;
 }
コード例 #31
0
ファイル: NetStream.cs プロジェクト: respu/SimplyFast
 public NetStream(Socket socket, IPool<SocketAsyncEventArgs> pool)
     : base(socket)
 {
     _pool = pool;
 }
コード例 #32
0
ファイル: PoolConfig.cs プロジェクト: BeauPrime/BeauPools
 static private void PooledObjectOnDestruct(IPool <T> inPool, T inElement)
 {
     ((IPooledObject <T>)inElement).OnDestruct();
 }
コード例 #33
0
ファイル: PoolConfig.cs プロジェクト: BeauPrime/BeauPools
 static private void PooledObjectOnFree(IPool <T> inPool, T inElement)
 {
     ((IPooledObject <T>)inElement).OnFree();
 }
コード例 #34
0
ファイル: PoolConfig.cs プロジェクト: BeauPrime/BeauPools
 static private void PooledConstructHandlerOnDestruct(IPool <T> inPool, T inElement)
 {
     ((IPoolConstructHandler)inElement).OnDestruct();
 }
コード例 #35
0
 public Survey(SmartFamilySurveyContext context, IPool pool)
 {
     _context = context;
     _pool    = pool;
 }
コード例 #36
0
ファイル: PoolConfig.cs プロジェクト: BeauPrime/BeauPools
 static private void PooledAllocHandlerOnFree(IPool <T> inPool, T inElement)
 {
     ((IPoolAllocHandler)inElement).OnFree();
 }
コード例 #37
0
 public EnemyCollisionSystem(IPoolManager poolManager, IEventSystem eventSystem)
 {
     _pool        = poolManager.GetPool("");
     _eventSystem = eventSystem;
 }
コード例 #38
0
ファイル: PoolTests.cs プロジェクト: ycarowr/CardGameHexBoard
 public override void Create() => _pool = new Pool <CardPool>(Parameters, Dispatcher);
コード例 #39
0
ファイル: Pool.cs プロジェクト: BeauPrime/BeauPools
 static private void IDisposableOnDispose <T>(IPool <T> inPool, T inElement) where T : class, IDisposable
 {
     inElement.Dispose();
 }
コード例 #40
0
 public VanillaServer(IPool pool, IMinerManager minerManager, IJobManager jobManager)
 {
     _pool = pool;
     _minerManager = minerManager;
     _jobManager = jobManager;
 }
コード例 #41
0
ファイル: RoutedEventData.cs プロジェクト: RUSshy/ultraviolet
 /// <summary>
 /// Releases any references held by the object.
 /// </summary>
 protected virtual void OnReleased()
 {
     this.originalSource = null;
     this.source = null;
     this.handled = false;
     this.autorelease = true;
     this.origin = null;
 }
コード例 #42
0
ファイル: Pool.cs プロジェクト: BeauPrime/BeauPools
 /// <summary>
 /// Allocates enough elements to fill the given array, starting from the given index.
 /// Returns the total number of allocated elements.
 /// </summary>
 static public int Alloc <T>(this IPool <T> inThis, T[] inDest, int inStartIndex) where T : class
 {
     return(Alloc <T>(inThis, inDest, inStartIndex, inDest.Length - inStartIndex));
 }
コード例 #43
0
        /// <inheritdoc/>
        protected override void OnRetrieved(IPool origin, DependencyObject source, Boolean handled, Boolean autorelease)
        {
            Valid = true;

            base.OnRetrieved(origin, source, handled, autorelease);
        }
コード例 #44
0
ファイル: Pool.cs プロジェクト: BeauPrime/BeauPools
 /// <summary>
 /// Allocates enough elements to fill the given array.
 /// Returns the total number of allocated elements.
 /// </summary>
 static public int Alloc <T>(this IPool <T> inThis, T[] inDest) where T : class
 {
     return(Alloc <T>(inThis, inDest, 0, inDest.Length));
 }
コード例 #45
0
 public AsyncSocketSession(Socket client, IPool<SocketAsyncEventArgs> saePoolForReceive)
     : this(client, saePoolForReceive, false)
 {
 }
コード例 #46
0
 public void InitializeWithPool(IPool pool)
 {
     _Pool = pool;
 }
コード例 #47
0
ファイル: Pool.cs プロジェクト: BeauPrime/BeauPools
 /// <summary>
 /// Prefills the pool to capacity.
 /// </summary>
 static public void Prewarm <T>(this IPool <T> inThis) where T : class
 {
     inThis.Prewarm(inThis.Capacity);
 }
コード例 #48
0
        public static NetworkChannel OpenChannel(string targetServerName, ISimpleBufferPool socketStreamBufferPool, IPool <SocketStreamAsyncArgs> socketStreamAsyncArgPool, SocketStream.ISocketStreamPerfCounters perfCtrs, bool suppressTransparentCompression)
        {
            if (socketStreamAsyncArgPool != null ^ socketStreamBufferPool != null)
            {
                string message = "SocketStream use requires both pools or neither";
                throw new ArgumentException(message);
            }
            ITcpConnector    tcpConnector = Dependencies.TcpConnector;
            NetworkPath      netPath      = null;
            TcpClientChannel tcpChannel   = tcpConnector.OpenChannel(targetServerName, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs, out netPath);

            return(NetworkChannel.FinishConnect(tcpChannel, netPath, suppressTransparentCompression));
        }
コード例 #49
0
        /// <inheritdoc/>
        protected override void OnRetrieved(IPool origin, DependencyObject source, Boolean handled, Boolean autorelease)
        {
            HorizontalOffset = 0;
            HorizontalChange = 0;
            VerticalOffset = 0;
            VerticalChange = 0;
            ExtentWidth = 0;
            ExtentWidthChange = 0;
            ExtentHeight = 0;
            ExtentHeightChange = 0;
            ViewportWidth = 0;
            ViewportWidthChange = 0;
            ViewportHeight = 0;
            ViewportHeightChange = 0;

            base.OnRetrieved(origin, source, handled, autorelease);
        }
コード例 #50
0
ファイル: PoolAddedEvent.cs プロジェクト: chaolunner/Rplidar
 public PoolAddedEvent(IPool pool)
 {
     Pool = pool;
 }
コード例 #51
0
        public virtual void Initialize(IAppSession appSession)
        {
            AppSession = appSession;

            DataProcessor = appSession.CreatePipelineProcessor();

            Config = appSession.Config;
            SyncSend = Config.SyncSend;
            m_SendingQueuePool = ((SocketServerBase)((ISocketServerAccessor)appSession.AppServer).SocketServer).SendingQueuePool;

            SendingQueue queue = m_SendingQueuePool.Get();
            m_SendingQueue = queue;
            queue.StartEnqueue();
        }
コード例 #52
0
 internal Noble(int victoryPoints, IPool cost, string name = null)
 {
     Cost          = cost ?? throw new ArgumentNullException(nameof(cost));
     VictoryPoints = victoryPoints;
     Name          = name ?? AutoName();
 }
コード例 #53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StratumServer"/> class.
 /// </summary>
 /// <param name="pool"></param>
 /// <param name="minerManager">The miner manager.</param>
 /// <param name="jobManager"></param>
 public StratumServer(IPool pool, IMinerManager minerManager, IJobManager jobManager)
 {
     _pool = pool;
     _minerManager = minerManager;
     _jobManager = jobManager;
 }
コード例 #54
0
 public void Reset(IPool pool)
 {
     _e = _eSym = null;
 }
コード例 #55
0
ファイル: PoolTests.cs プロジェクト: ycarowr/CardGameHexBoard
 public void OnCreatePool(IPool <CardPool> pool) => _isCreated = true;
コード例 #56
0
 public SelfDestructionSystem(IPoolManager poolManager)
 {
     _defaultPool = poolManager.GetPool();
 }
コード例 #57
0
ファイル: NetSocket.cs プロジェクト: respu/SimplyFast
 public NetSocket(Socket socket, IPool<SocketAsyncEventArgs> pool)
 {
     _stream = new NetStream(socket, pool);
 }
コード例 #58
0
 public CoinSystem(IPoolManager poolManager)
 {
     _pool = poolManager.GetPool("");
 }
コード例 #59
0
        public virtual bool Start()
        {
            IsStopped = false;

            ILog log = AppServer.Logger;

            try
            {
                using (var transaction = new LightweightTransaction())
                {
                    var config = this.AppServer.Config;

                    transaction.RegisterItem(ServerResourceItem.Create<SaePoolResource, IPool<SaeState>>(
                        (pool) => this.m_SaePool = pool, config));

                    transaction.RegisterItem(ServerResourceItem.Create<BufferStatePoolResource, IPool<BufferState>>(
                        (pool) => this.m_BufferStatePool = pool, config));

                    transaction.RegisterItem(ServerResourceItem.Create<SendingQueuePoolResource, IPool<SendingQueue>>(
                        (pool) => this.SendingQueuePool = pool, config));

                    if (!StartListeners())
                        return false;

                    m_ServerResources = transaction.Items.OfType<ServerResourceItem>().ToArray();
                    transaction.Commit();
                }
            }
            catch (Exception e)
            {
                log.Error(e);
                return false;
            }

            IsRunning = true;
            return true;
        }
コード例 #60
0
 public PoolRemovedEvent(IPool pool)
 {
     Pool = pool;
 }