Commit 057b1c47 authored by shajiaiming's avatar shajiaiming

交易组验证

parents d345981e bba41db2
......@@ -82,28 +82,29 @@ class CrossChainController extends BaseController
->andWhere(['step' => $val['step']])
->andWhere(['<>', 'msg', 'success'])
->one();
if(false == $model) continue;
$node_params = $model->transfer_url;
$node_params = explode(':', $node_params);
$node_params = [
'scheme' => $node_params[0],
'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : ''
];
$service = new Chain33Service($node_params);
$send_result = $model->send_result;
$result = $service->QueryTransaction($send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$model->query_result = 'success';
$model->msg = 'success';
$model->save();
continue;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$model->query_result = 'success';
$model->msg = 'success';
$model->save();
continue;
} else {
// $node_params = $model->transfer_url;
// $node_params = explode(':', $node_params);
// $node_params = [
// 'scheme' => $node_params[0],
// 'host' => str_replace('//', '', $node_params[1]),
// 'port' => isset($node_params[2]) ? $node_params[2] : ''
// ];
// $service = new Chain33Service($node_params);
// $send_result = $model->send_result;
// $result = $service->QueryTransaction($send_result);
// if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
// $model->query_result = 'success';
// $model->msg = 'success';
// $model->save();
// continue;
// } else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
// $model->query_result = 'success';
// $model->msg = 'success';
// $model->save();
// continue;
// } else {
$model->txhex = $val['tx'];
$model->transfer_url = $val['url'];
$model->send_result = 0;
......@@ -111,7 +112,7 @@ class CrossChainController extends BaseController
$model->msg = 0;
$model->save();
continue;
}
// }
}
$code = 0;
$msg = 'success';
......
......@@ -99,15 +99,16 @@ class CrossChainController extends Controller
// 'port' => 8801
// ];
// 测试环境查询共识高度
// $node_params = [
// 'scheme' => 'http',
// 'host' => '172.16.100.77',
// 'port' => 8801
// ];
// $service = new Chain33Service($node_params);
// $result = $service->getHeight();
// $consensHeight = $result['result']['consensHeight'];
//测试环境查询共识高度
//3步交易情况下需要做高度判断,2步交易注释IF判断
$node_params = [
'scheme' => 'http',
'host' => '172.16.100.77',
'port' => 8801
];
$service = new Chain33Service($node_params);
$result = $service->getHeight();
$consensHeight = $result['result']['consensHeight'];
$current_time = time();
foreach ($model as $val) {
......@@ -118,10 +119,10 @@ class CrossChainController extends Controller
'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : ''
];
$service = new Chain33Service($node_params);
$send_result = $val['send_result'];
$result = $service->QueryTransaction($send_result);
#$result = $service->QueryTransaction($send_result);
$switch = true;
$result = $this->queryTransaction($node_params, $send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$redis->hdel(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
......@@ -165,9 +166,10 @@ class CrossChainController extends Controller
doEnd :
// if (CoinCrossChain::RECHARGE == $val['is_with_draw'] && $val['step'] == 1 && $switch && isset($height) && ($consensHeight < $height)) {
// continue;
// }
//3步交易情况下需要做高度判断,2步交易注释IF判断
if (CoinCrossChain::RECHARGE == $val['is_with_draw'] && $val['step'] == 1 && $switch && isset($height) && ($consensHeight < $height)) {
continue;
}
$currentModel = CoinCrossChain::findOne($val['id']);
$currentModel->query_result = $query_result;
......@@ -175,7 +177,7 @@ class CrossChainController extends Controller
$currentModel->save();
$count = CoinCrossChain::find()->where(['transfer_number' => $val['transfer_number']])->andWhere(['query_result' => 'success'])->count();
if (2 == $count) {
if (3 == $count) {
$key = $val['address'] . '_' . $val['is_with_draw'];
if ($redis->exists($key)) {
$redis->del($key);
......@@ -187,13 +189,31 @@ class CrossChainController extends Controller
return 0;
}
protected function queryTransaction($node_params, $result)
protected function queryTransaction($node_params, $send_result)
{
// static $result = [];
// $service = new Chain33Service($node_params);
// $result = $service->QueryTransaction($send_result);
// echo json_encode($result).PHP_EOL;
// if (isset($result['result']['tx']['next'])) {
// $this->queryTransaction($node_params, $result['result']['tx']['next']);
// }
// return $result;
static $result = [];
$service = new Chain33Service($node_params);
$result = $service->QueryTransaction($result);
if (!isset($result['result']['tx']['next'])) {
return $result;
$result = $service->QueryTransaction($send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
if (isset($result['result']['tx']['next'])) {
$this->queryTransaction($node_params, $result['result']['tx']['next']);
}
}
if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']){
if (isset($result['result']['tx']['next'])) {
$this->queryTransaction($node_params, $result['result']['tx']['next']);
}
}
return $result;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment