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
339caf98
Commit
339caf98
authored
Sep 10, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
0ef821ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
17 deletions
+45
-17
Chain33Service.php
common/service/chain33/Chain33Service.php
+9
-0
GameBetController.php
console/controllers/GameBetController.php
+36
-17
No files found.
common/service/chain33/Chain33Service.php
View file @
339caf98
...
...
@@ -298,6 +298,15 @@ class Chain33Service
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
}
public
function
getBlock2MainInfo
(
$start
,
$end
)
{
$params
=
[
"Start"
=>
$start
,
"End"
=>
$end
,
];
return
$this
->
send
(
$params
,
'paracross.GetBlock2MainInfo'
);
}
public
function
sendTrade
(
$data
)
{
$params
=
[
...
...
console/controllers/GameBetController.php
View file @
339caf98
...
...
@@ -4,6 +4,7 @@ namespace console\controllers;
use
common\business\Chain33Business
;
use
common\models\psources\CoinGameBet
;
use
common\service\chain33\Chain33Service
;
use
yii\console\Controller
;
use
Yii
;
...
...
@@ -76,32 +77,38 @@ class GameBetController extends Controller
public
function
actionBetUpdate
()
{
$service
=
new
Chain33Business
();
$node_params
=
[
'scheme'
=>
'https'
,
'host'
=>
'jiedian1.bityuan.com'
,
'port'
=>
8801
];
$result
=
$service
->
getLastHeader
(
$node_params
);
$main_height
=
isset
(
$result
[
'result'
][
'height'
])
?
$result
[
'result'
][
'height'
]
:
0
;
$safe_main_height
=
$main_height
-
14
;
$nodes
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
if
(
empty
(
$nodes
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'无节点'
.
PHP_EOL
;
return
0
;
}
foreach
(
$nodes
as
$key
=>
$node
)
{
$service
=
new
Chain33Business
();
$result
=
$service
->
getGameStatus
(
$node
);
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
$result
[
'msg'
]
.
PHP_EOL
;
continue
;
$service
=
new
Chain33Service
(
$node
);
$result
=
$service
->
getLastHeader
();
$height
=
$result
[
'result'
][
'height'
];
$main_info
=
$service
->
getBlock2MainInfo
(
$height
-
14
,
$height
);
$items
=
$main_info
[
'result'
][
'items'
];
$items
=
$this
->
arraySort
(
$items
,
'mainHeight'
);
foreach
(
$items
as
$item
)
{
if
(
$safe_main_height
>
$item
[
'mainHeight'
])
{
$safe_height
=
$item
[
'height'
];
break
;
}
}
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
))
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'error'
.
PHP_EOL
;
continue
;
}
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$current_height
=
$resultJSON
[
'height'
];
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'当前高度为:'
.
$current_height
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'当前主链高度为:'
.
$main_height
.
';当前平行链高度为:'
.
$height
.
';当前安全高度为:'
.
$safe_height
.
PHP_EOL
;
$models
=
CoinGameBet
::
find
()
->
select
(
'round'
)
->
where
([
'and'
,
[
'valid'
=>
CoinGameBet
::
VAILD_FALSE
],
[
'<'
,
'height'
,
$
current_height
-
14
],
[
'<'
,
'height'
,
$
safe_height
],
[
'platform'
=>
$key
]
])
->
all
();
if
(
empty
(
$models
))
{
...
...
@@ -112,7 +119,8 @@ class GameBetController extends Controller
foreach
(
$models
as
$model
)
{
$valid_arr
[]
=
$model
->
round
;
}
$result
=
$service
->
getBetStatus
(
''
,
''
,
$valid_arr
,
$node
);
$business
=
new
Chain33Business
();
$result
=
$business
->
getBetStatus
(
''
,
''
,
$valid_arr
,
$node
);
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
continue
;
...
...
@@ -145,4 +153,14 @@ class GameBetController extends Controller
return
0
;
}
protected
function
arraySort
(
$array
,
$keys
,
$sort
=
SORT_DESC
)
{
$keysValue
=
[];
foreach
(
$array
as
$k
=>
$v
)
{
$keysValue
[
$k
]
=
$v
[
$keys
];
}
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
}
}
\ 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