LCOV - code coverage report
Current view: top level - lib/src/messages - ethereum_sync_status.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 22 22 100.0 %
Date: 2018-01-19 11:13:13 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * Package : Ethereum
       3             :  * Author : S. Hamblett <steve.hamblett@linux.com>
       4             :  * Date   : 08/01/2017
       5             :  * Copyright :  S.Hamblett
       6             :  *
       7             :  * A JSON RPC 2.0 client for Ethereum
       8             :  */
       9             : 
      10             : part of ethereum;
      11             : 
      12             : /// Sync status message
      13             : class EthereumSyncStatus {
      14           1 :   EthereumSyncStatus();
      15             : 
      16           2 :   EthereumSyncStatus.fromMap(Map result) {
      17           2 :     construct(result);
      18             :   }
      19             : 
      20             :   /// Syncing indicator, true if syncing
      21             :   bool _syncing = false;
      22             : 
      23           2 :   bool get syncing => _syncing;
      24             : 
      25             :   /// Starting block, only valid if syncing
      26             :   int _startingBlock;
      27             : 
      28           2 :   int get startingBlock => _startingBlock;
      29             : 
      30             :   /// Current block, only valid if syncing
      31             :   int _currentBlock;
      32             : 
      33           2 :   int get currentBlock => _currentBlock;
      34             : 
      35             :   /// Highest block, only valid if syncing
      36             :   int _highestBlock;
      37             : 
      38           2 :   int get highestBlock => _highestBlock;
      39             : 
      40             :   /// Construct from the supplied Map, only check for the keys we need.
      41             :   void construct(Map data) {
      42           4 :     if (!(data[ethResultKey] is bool)) {
      43           2 :       _syncing = true;
      44           2 :       if (data.containsKey('startingBlock')) {
      45           3 :         _startingBlock = EthereumUtilities.hexToInt(data['startingBlock']);
      46             :       }
      47           2 :       if (data.containsKey('currentBlock')) {
      48           3 :         _currentBlock = EthereumUtilities.hexToInt(data['currentBlock']);
      49             :       }
      50           2 :       if (data.containsKey('highestBlock')) {
      51           3 :         _highestBlock = EthereumUtilities.hexToInt(data['highestBlock']);
      52             :       }
      53             :     }
      54             :   }
      55             : 
      56             :   // To string
      57             :   String toString() {
      58             :     String ret =
      59           4 :         "Ethereum Sync Status :" + "\n" + "  Syncing : $syncing" + "\n";
      60           1 :     if (syncing) {
      61           3 :       ret += "  Starting Block : $startingBlock" +
      62           1 :           "\n" +
      63           2 :           "  Current Block : $currentBlock" +
      64           1 :           "\n" +
      65           2 :           "  Highest Block : $highestBlock" +
      66             :           "\n";
      67             :     }
      68             : 
      69             :     return ret;
      70             :   }
      71             : }

Generated by: LCOV version 1.12