Skip to content

Commit 48790fd

Browse files
authored
Merge pull request #32 from fzxu/timeout
add http timeout
2 parents 66cda24 + 782d167 commit 48790fd

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.5
2+
3+
- Support adding timeout on http request
4+
15
## 0.4.4
26

37
- Support abi float32 and float64

example/eosdart_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:eosdart/eosdart.dart';
22

33
main() {
44
EOSClient client = EOSClient('https://eos.greymass.com', 'v1');
5-
// EOSClient client = EOSClient('http://127.0.0.1:8888', 'v1');
5+
// EOSClient client = EOSClient('http://127.0.0.1:8888', 'v1', httpTimeout: 15);
66

77
// Get EOS Node Info
88
client.getInfo().then((NodeInfo nodeInfo) {

lib/src/client.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ class EOSClient {
2323
final String _nodeURL;
2424
final String _version;
2525
int expirationInSec;
26+
int httpTimeout;
2627
Map<String, ecc.EOSPrivateKey> keys = Map();
2728

2829
/// Converts abi files between binary and structured form (`abi.abi.json`) */
2930
Map<String, Type> abiTypes;
3031
Map<String, Type> transactionTypes;
3132

3233
/// Construct the EOS client from eos node URL
33-
EOSClient(this._nodeURL, this._version,
34-
{this.expirationInSec = 180, List<String> privateKeys = const []}) {
34+
EOSClient(
35+
this._nodeURL,
36+
this._version, {
37+
this.expirationInSec = 180,
38+
List<String> privateKeys = const [],
39+
this.httpTimeout = 10,
40+
}) {
3541
_mapKeys(privateKeys);
3642

3743
abiTypes = ser.getTypesFromAbi(
@@ -56,6 +62,7 @@ class EOSClient {
5662
http
5763
.post('${this._nodeURL}/${this._version}${path}',
5864
body: json.encode(body))
65+
.timeout(Duration(seconds: this.httpTimeout))
5966
.then((http.Response response) {
6067
if (response.statusCode >= 300) {
6168
completer.completeError(response.body);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: eosdart
22
description: EOSIO-based blockchain RPC API client in Dart language
3-
version: 0.4.4
3+
version: 0.4.5
44
homepage: https://github.com/primes-network/eosdart
55
author: primes-network <primes.ntwk@gmail.com>
66

0 commit comments

Comments
 (0)