/// <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()); }; }
public AsyncStreamSocketSession(Socket client, SslProtocols security, IPool<BufferState> bufferStatePool, bool isReset) : base(client) { SecureProtocol = security; m_BufferStatePool = bufferStatePool; m_IsReset = isReset; }
public void Setup() { b = new Binding (); b.ToPool (); binding = (b as IPool); }
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; } }
/// <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()); }; }
public VanillaServer(IPool pool, IMinerManager minerManager, IJobManager jobManager, ICoinConfig coinConfig) { _pool = pool; _minerManager = minerManager; _jobManager = jobManager; _logger = Log.ForContext<VanillaServer>().ForContext("Component", coinConfig.Name); }
/// <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); }
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); }
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); }
/// <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); }
/// <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); }
/// <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. }
/// <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); }
public override object Resolve(CreationContext context) { if (pool == null) { lock (ComponentActivator) { if (pool == null) { pool = CreatePool(initialSize, maxSize); } } } return pool.Request(context); }
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; }
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); }
/// <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; }
/// <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>); }
/// <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)); }
public void Init(IPool pool) { }
//public bool isFromPool(final Pool<? extends PoolItem> pPool) { public bool IsFromPool(/* final */ IPool pPool) { return pPool == this.mParent; }
public UdpSocketListener(ListenerInfo info, IPool<SaeState> saePool) : base(info) { m_SaePool = saePool; }
public GetworkServer(IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager) { _pool = pool; _minerManager = minerManager; _logger = Log.ForContext <GetworkServer>().ForContext("Component", poolConfig.Coin.Name); }
public PoolElementUsageHandler(IPool <TElement> pool, TElement element) { _used = false; _pool = pool; _element = element; }
void IClientPoolable.OnInstanceCreated(Pool pool) { _pool = pool; _go = gameObject; }
public AutoReturnTakeTokens(IPool tokensToTake) { m_TokensToTake = tokensToTake ?? throw new ArgumentNullException(nameof(tokensToTake)); }
public UdpSocketListener(ListenerInfo info, IPool <SaeState> saePool) : base(info) { m_SaePool = saePool; }
public AsyncStreamSocketSession(Socket client, SslProtocols security, IPool <BufferState> bufferStatePool) : this(client, security, bufferStatePool, false) { }
public PooledFactory(IPool <T> pool) { this.pool = pool ?? throw new ArgumentNullException(); }
public AsyncSocketSession(Socket client, IPool<SocketAsyncEventArgs> saePoolForReceive, bool isReset) : base(client) { m_SaePoolForReceive = saePoolForReceive; m_IsReset = isReset; }
public NetStream(Socket socket, IPool<SocketAsyncEventArgs> pool) : base(socket) { _pool = pool; }
static private void PooledObjectOnDestruct(IPool <T> inPool, T inElement) { ((IPooledObject <T>)inElement).OnDestruct(); }
static private void PooledObjectOnFree(IPool <T> inPool, T inElement) { ((IPooledObject <T>)inElement).OnFree(); }
static private void PooledConstructHandlerOnDestruct(IPool <T> inPool, T inElement) { ((IPoolConstructHandler)inElement).OnDestruct(); }
public Survey(SmartFamilySurveyContext context, IPool pool) { _context = context; _pool = pool; }
static private void PooledAllocHandlerOnFree(IPool <T> inPool, T inElement) { ((IPoolAllocHandler)inElement).OnFree(); }
public EnemyCollisionSystem(IPoolManager poolManager, IEventSystem eventSystem) { _pool = poolManager.GetPool(""); _eventSystem = eventSystem; }
public override void Create() => _pool = new Pool <CardPool>(Parameters, Dispatcher);
static private void IDisposableOnDispose <T>(IPool <T> inPool, T inElement) where T : class, IDisposable { inElement.Dispose(); }
public VanillaServer(IPool pool, IMinerManager minerManager, IJobManager jobManager) { _pool = pool; _minerManager = minerManager; _jobManager = jobManager; }
/// <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; }
/// <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)); }
/// <inheritdoc/> protected override void OnRetrieved(IPool origin, DependencyObject source, Boolean handled, Boolean autorelease) { Valid = true; base.OnRetrieved(origin, source, handled, autorelease); }
/// <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)); }
public AsyncSocketSession(Socket client, IPool<SocketAsyncEventArgs> saePoolForReceive) : this(client, saePoolForReceive, false) { }
public void InitializeWithPool(IPool pool) { _Pool = pool; }
/// <summary> /// Prefills the pool to capacity. /// </summary> static public void Prewarm <T>(this IPool <T> inThis) where T : class { inThis.Prewarm(inThis.Capacity); }
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)); }
/// <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); }
public PoolAddedEvent(IPool pool) { Pool = pool; }
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(); }
internal Noble(int victoryPoints, IPool cost, string name = null) { Cost = cost ?? throw new ArgumentNullException(nameof(cost)); VictoryPoints = victoryPoints; Name = name ?? AutoName(); }
/// <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; }
public void Reset(IPool pool) { _e = _eSym = null; }
public void OnCreatePool(IPool <CardPool> pool) => _isCreated = true;
public SelfDestructionSystem(IPoolManager poolManager) { _defaultPool = poolManager.GetPool(); }
public NetSocket(Socket socket, IPool<SocketAsyncEventArgs> pool) { _stream = new NetStream(socket, pool); }
public CoinSystem(IPoolManager poolManager) { _pool = poolManager.GetPool(""); }
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; }
public PoolRemovedEvent(IPool pool) { Pool = pool; }