public BlockNotifier(TimeSpan period, RPCClient rpcClient, P2pNode p2pNode) : base(period, null) { RpcClient = Guard.NotNull(nameof(rpcClient), rpcClient); P2pNode = p2pNode; ProcessedBlocks = new List <BlockHeader>(); P2pNode.BlockInv += P2pNode_BlockInv; }
void OnGUI() { if (GUI.Button(new Rect(10, 10, 150, 100), "Add")) { P2pNode node = (P2pNode)objPool.GetOneObject(); node.transform.position = transform.position + new Vector3(randomFloat, randomFloat, randomFloat); node.transform.SetParent(transform); int nodeId; if (nodeIdQueue.Count > 0) { nodeId = nodeIdQueue.Dequeue(); } else { nodeId = maxNodeId; maxNodeId++; } node.InitP2pObject(nodeId); nodeList.Add(nodeId, node); } if (GUI.Button(new Rect(200, 10, 150, 100), "delete")) { if (nodeList.Count > 0) { int nodeId = randomNodeId; DebugLogMain.hLog("" + nodeId); PoolObject pObj = nodeList[nodeId]; nodeList.Remove(nodeId); nodeIdQueue.Enqueue(nodeId); pObj.RecycleSelf(); } /* * if (nodeList.Count > 0) { * int index = Random.Range(0, nodeList.Count); * Debug.Log("" + index); * PoolObject obj = nodeList[index]; * nodeList.Remove(index); * //objList.RemoveAt(index); * obj.RecycleSelf(); * } */ } if (GUI.Button(new Rect(400, 10, 150, 100), "Recycle All")) { objPool.RecycleAll(); } if (GUI.Button(new Rect(600, 10, 150, 100), "Initialize Pool")) { objPool.InitPool(5); } }
private async Task InitializeP2pAsync(Network network, EndPoint endPoint, CancellationToken cancel) { Guard.NotNull(nameof(network), network); Guard.NotNull(nameof(endPoint), endPoint); // We have to find it, because it's cloned by the node and not perfectly cloned (event handlers cannot be cloned.) P2pNode = new P2pNode(network, endPoint, new MempoolService(), $"/WasabiCoordinator:{Constants.BackendMajorVersion}/"); await P2pNode.ConnectAsync(cancel).ConfigureAwait(false); HostedServices.Register(new BlockNotifier(TimeSpan.FromSeconds(7), RpcClient, P2pNode), "Block Notifier"); }
protected override async Task ActionAsync(CancellationToken cancel) { Logger.LogInfo("Trying to reconnect to P2P..."); if (await P2pNode.TryDisconnectAsync(cancel).ConfigureAwait(false)) { await P2pNode.ConnectAsync(cancel).ConfigureAwait(false); Logger.LogInfo("Successfully reconnected to P2P."); Success.TrySetResult(true); } }
protected override async Task ActionAsync(CancellationToken cancel) { try { Logger.LogInfo("Trying to reconnect to P2P..."); P2pNode.Disconnect(); await P2pNode.ConnectAsync(cancel).ConfigureAwait(false); } catch { P2pNode.Disconnect(); throw; } Logger.LogInfo("Successfully reconnected to P2P."); Success.TrySetResult(null); }
public P2pReconnector(TimeSpan period, P2pNode p2pNode) : base(period) { P2pNode = Guard.NotNull(nameof(p2pNode), p2pNode); Success = new TaskCompletionSource <object>(); }
public BlockNotifier(TimeSpan period, IRPCClient rpcClient, P2pNode p2pNode = null) : base(period) { RpcClient = Guard.NotNull(nameof(rpcClient), rpcClient); P2pNode = p2pNode; ProcessedBlocks = new List <uint256>(); if (p2pNode is { })
/// <param name="period">How often to mirror the mempool.</param> public MempoolMirror(TimeSpan period, IRPCClient rpc, P2pNode node) : base(period) { Rpc = rpc; Node = node; }
public P2pReconnector(TimeSpan period, P2pNode p2pNode) : base(period, false) { P2pNode = Guard.NotNull(nameof(p2pNode), p2pNode); }