Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
057b1c47
Commit
057b1c47
authored
Sep 27, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
交易组验证
parents
d345981e
bba41db2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
42 deletions
+64
-42
CrossChainController.php
api/controllers/CrossChainController.php
+23
-22
CrossChainController.php
console/controllers/CrossChainController.php
+41
-20
No files found.
api/controllers/CrossChainController.php
View file @
057b1c47
...
...
@@ -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'
;
...
...
console/controllers/CrossChainController.php
View file @
057b1c47
...
...
@@ -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'
]);
}
}
$this
->
queryTransaction
(
$node_params
,
$result
[
'result'
][
'tx'
][
'next'
]);
return
$result
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment