浏览代码

修改表数据获取方法

solupro 5 年之前
父节点
当前提交
99ad71b57a
共有 1 个文件被更改,包括 16 次插入3 次删除
  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']));