Skip to content

Commit

Permalink
Merge pull request primes-network#32 from fzxu/timeout
Browse files Browse the repository at this point in the history
add http timeout
  • Loading branch information
fzxu authored Jun 27, 2020
2 parents 66cda24 + 782d167 commit 48790fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.5

- Support adding timeout on http request

## 0.4.4

- Support abi float32 and float64
Expand Down
2 changes: 1 addition & 1 deletion example/eosdart_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:eosdart/eosdart.dart';

main() {
EOSClient client = EOSClient('https://eos.greymass.com', 'v1');
// EOSClient client = EOSClient('http://127.0.0.1:8888', 'v1');
// EOSClient client = EOSClient('http://127.0.0.1:8888', 'v1', httpTimeout: 15);

// Get EOS Node Info
client.getInfo().then((NodeInfo nodeInfo) {
Expand Down
11 changes: 9 additions & 2 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@ class EOSClient {
final String _nodeURL;
final String _version;
int expirationInSec;
int httpTimeout;
Map<String, ecc.EOSPrivateKey> keys = Map();

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

/// Construct the EOS client from eos node URL
EOSClient(this._nodeURL, this._version,
{this.expirationInSec = 180, List<String> privateKeys = const []}) {
EOSClient(
this._nodeURL,
this._version, {
this.expirationInSec = 180,
List<String> privateKeys = const [],
this.httpTimeout = 10,
}) {
_mapKeys(privateKeys);

abiTypes = ser.getTypesFromAbi(
Expand All @@ -56,6 +62,7 @@ class EOSClient {
http
.post('${this._nodeURL}/${this._version}${path}',
body: json.encode(body))
.timeout(Duration(seconds: this.httpTimeout))
.then((http.Response response) {
if (response.statusCode >= 300) {
completer.completeError(response.body);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: eosdart
description: EOSIO-based blockchain RPC API client in Dart language
version: 0.4.4
version: 0.4.5
homepage: https://github.com/primes-network/eosdart
author: primes-network <[email protected]>

Expand Down

0 comments on commit 48790fd

Please sign in to comment.