Selaa lähdekoodia

修改表数据获取方法

solupro 5 vuotta sitten
vanhempi
commit
99ad71b57a
1 muutettua tiedostoa jossa 16 lisäystä ja 3 poistoa
  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']));