private Web3 CreateBlockchainClient(ILogFactory logFactory, string nodeUrl) { if (nodeUrl.StartsWith("ws")) { var wsClient = new WebSocketClient(nodeUrl, log: logFactory.CreateNethereumLog(this)); return(new Web3(wsClient)); } return(new Web3(nodeUrl, logFactory.CreateNethereumLog(this))); }
public EthNodeClientBase(Func <Task <string[]> > connStringListGetter, ILogFactory log, TimeSpan?webSocketConnectionTimeout) { _connStringListGetter = connStringListGetter; _log = log.CreateLog(this); _nethereumLog = log.CreateNethereumLog(this); UpdateConnectionList(connStringListGetter.Invoke().Result); SetActiveConnectionPool(); _timer = new TimerTrigger(GetType().Name, TimeSpan.FromSeconds(300), log, TimerHandler); _timer.Start(); // setting up timeout for websocket connections ClientBase.ConnectionTimeout = webSocketConnectionTimeout ?? TimeSpan.FromSeconds(DefaultWebSocketConnectionTimeoutInSeconds); }
public BlockchainWrapper( Func <Task <string[]> > connStringListGetter, string tokenContractAddress, string tokenGatewayContractAddress, TimeSpan?webSocketConnectionTimeout, IHttpClientFactory httpClientFactory, ILogFactory logFactory) { _timeout = webSocketConnectionTimeout ?? TimeSpan.FromSeconds(DefaultWebSocketConnectionTimeoutInSeconds); _log = logFactory.CreateLog(this); _nethereumLog = logFactory.CreateNethereumLog(this); _connStringListGetter = connStringListGetter; _tokenContractAddress = tokenContractAddress; _tokenGatewayContractAddress = tokenGatewayContractAddress; _httpClientFactory = httpClientFactory; UpdateConnectionList(connStringListGetter.Invoke().Result); SetActiveConnectionPool(); _timer = new TimerTrigger(GetType().Name, TimeSpan.FromSeconds(300), logFactory, TimerHandler); // setting up timeout for websocket connections ClientBase.ConnectionTimeout = _timeout; }