Browse Source

修改表数据获取方法

solupro 5 years ago
parent
commit
99ad71b57a
1 changed files with 16 additions and 3 deletions
  1. 16 3
      protected/models/Sync/Base.php

+ 16 - 3
protected/models/Sync/Base.php

@@ -172,12 +172,25 @@ class Sync_Base extends Singleton {
     }
 
     public function getNewestDatas($lower = null, $limit = 1000) {
-        $cmd = "cleos -u {$GLOBALS['eosUrl']} get table {$this->code} {$this->code} {$this->codeTable} --index {$this->index} --key-type {$this->keyType} -l {$limit} ";
+        $url = "{$GLOBALS['eosUrl']}v1/chain/get_table_rows";
+
+        $objHttp = new dwHttp();
+        $data = [
+            'scope' => $this->code,
+            'code' => $this->code,
+            'table' => $this->codeTable,
+            'json' => true,
+            'limit' => $limit,
+            'key_type' => $this->keyType,
+            'index_position' => $this->index,
+        ];
+
         if ($lower) {
-            $cmd .= " -L '{$lower}' ";
+            $data['lower_bound'] = $lower;
         }
 
-        $json = Eos::execCmd($cmd);
+        // 第一次2秒就超时
+        $json = $objHttp->post2($url, json_encode($data), 5, 2);
         $datas = json_decode($json, true);
 
         Eos::log("get {$this->code} {$this->codeTable} lower:{$lower}, count:" . count($datas['rows']));