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
54a4caa2
Commit
54a4caa2
authored
Sep 20, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3fa4f915
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
14 deletions
+129
-14
Chain33Business.php
common/business/Chain33Business.php
+101
-0
Chain33Service.php
common/service/chain33/Chain33Service.php
+12
-0
JugdeAwardJob.php
h5/job/JugdeAwardJob.php
+16
-14
No files found.
common/business/Chain33Business.php
View file @
54a4caa2
...
...
@@ -142,4 +142,105 @@ class Chain33Business
$service
=
new
Chain33Service
();
return
$service
->
getTxByAddr
(
$addr
,
$flag
,
$count
,
$direction
,
$height
,
$index
);
}
/**
* 获取用户首次交易区块信息
*
* @param string $address
* @param int $flag
* @return boolean|array
*/
public
static
function
getAddressFirstTransInfo
(
$address
,
$flag
)
{
$trans
=
Chain33Business
::
getTxByAddr
(
$address
,
$flag
,
1
,
1
,
0
,
0
);
if
(
$trans
[
'code'
]
==
0
)
{
return
$trans
[
'result'
][
'txInfos'
][
0
];
}
return
false
;
}
/**
* 获取用户最新交易区块信息
*
* @param string $address
* @param int $flag
* @return boolean|array
*/
public
static
function
getAddressLastTransInfo
(
$address
,
$flag
)
{
$trans
=
Chain33Business
::
getTxByAddr
(
$address
,
$flag
,
1
,
0
,
-
1
,
0
);
if
(
$trans
[
'code'
]
==
0
)
{
return
$trans
[
'result'
][
'txInfos'
][
0
];
}
return
false
;
}
/**
* 获取高度区间内的所有 txhash
*
* @param string $addr
* @param int $flag
* @param int $direction
* @param int $start_height
* @param int $end_height
* @return boolean|array
*/
public
static
function
getTxByAddrInRange
(
$addr
,
$flag
,
$direction
,
$start_height
,
$end_height
)
{
$result
=
[];
$trans_info
=
Chain33Business
::
getTxByAddr
(
$addr
,
$flag
,
0
,
0
,
-
1
,
0
);
if
(
$trans_info
[
'code'
]
==
0
)
{
$result
=
$trans_info
[
'result'
][
'txInfos'
];
}
// $first_info = Chain33Business::getAddressFirstTransInfo($addr, $flag);
// if ($first_info) {
// $height = $first_info['height'];
// if ($height <= $start_height) {
// //获取开始高度之后的所有信息
// if ($height == $start_height) {
// $result = array_merge($result, $first_info);
// }
// $trans_info = Chain33Business::getTxByAddr($addr, $flag, 0, 1, $start_height, 0);
// var_dump($trans_info);
// if ($trans_info['code'] == 0) {
// $trans_info = $trans_info['result']['txInfos'];
// $result = array_merge(array_column($trans_info, null, 'height'));
// }
// } else {
// $last_info = Chain33Business::getAddressLastTransInfo($addr, $flag);
// if ($last_info) {
// $height = $last_info['height'];
// if ($height == $end_height) {
// $result = array_merge($result, $first_info);
// }
// if ($height <= $end_height) {
// $height = -1;
// } else {
// $height = $end_height;
// }
// $trans_info = Chain33Business::getTxByAddr($addr, $flag, 0, 0, $height, 0);
// if ($trans_info['code'] == 0) {
// $trans_info = $trans_info['result']['txInfos'];
// $result = array_merge(array_column($trans_info, null, 'height'));
// }
// }
// }
// }
foreach
(
$result
as
$key
=>
$item
)
{
if
(
$item
[
'height'
]
>
$end_height
||
$item
[
'height'
]
<
$start_height
)
{
unset
(
$result
[
$key
]);
}
}
return
$result
;
}
/**
* @param array $hashes
* @return array
*/
public
static
function
getTxByHashs
(
$hashes
)
{
$service
=
new
Chain33Service
();
return
$service
->
getTxByHashes
(
$hashes
);
}
}
common/service/chain33/Chain33Service.php
View file @
54a4caa2
...
...
@@ -161,4 +161,16 @@ class Chain33Service
];
return
$this
->
send
(
$params
,
'Chain33.GetTxByAddr'
);
}
/**
* @param array $hashes
* @return array
*/
public
function
getTxByHashes
(
array
$hashes
)
{
$params
=
[
'hashes'
=>
$hashes
,
];
return
$this
->
send
(
$params
,
'Chain33.GetTxByHashes'
);
}
}
h5/job/JugdeAwardJob.php
View file @
54a4caa2
...
...
@@ -36,24 +36,27 @@ class JugdeAwardJob extends BaseObject implements JobInterface
if
(
$guess_result
)
{
$config
=
Yii
::
$app
->
params
[
'h5_activity'
][
'ZWG_GUESS_NEWBEE'
];
//获取区块间的所有交易(正常竞猜)
$trans_normal
=
Chain33Business
::
getTxByAddr
(
$config
[
'from_normal'
],
2
,
0
,
0
,
$guess_result
->
end_height
,
0
);
$trans_normal
=
Chain33Business
::
getTxByAddr
(
'1EZxpc1tnKtmQkUHcABXA6Dsn7e7zuhD2p'
,
2
,
0
,
0
,
$guess_result
->
end_height
,
0
);
if
(
$trans_normal
[
'code'
]
!=
0
)
{
return
0
;
}
else
{
$trans_normal
=
$trans_normal
[
'result'
][
'txInfos'
];
var_dump
(
$trans_normal
);
die
();
}
// $trans_normal = Chain33Business::getTxByAddrInRange($config['from_normal'], 2, 0, $guess_result->start_height, $guess_result->end_height);
$trans_normal
=
Chain33Business
::
getTxByAddrInRange
(
'14o9MHrrLfpsXf7wu4H4YRwvy84fjd7uaj'
,
2
,
0
,
710900
,
715345
);
$trans_new
=
Chain33Business
::
getTxByAddrInRange
(
$config
[
'to'
],
2
,
0
,
$guess_result
->
start_height
,
$guess_result
->
end_height
);
$trans
=
array_merge
(
$trans_normal
,
$trans_new
);
$txhashs
=
array_column
(
$trans
,
'hash'
);
$trans_info
=
Chain33Business
::
getTxByHashs
(
$txhashs
);
if
(
$trans_info
[
'code'
]
==
0
)
{
$trans_info
=
$trans_info
[
'result'
][
'txs'
];
if
(
is_array
(
$trans_info
))
{
foreach
(
$trans_info
as
$k
=>
$v
)
{
//收集数据
}
}
}
$loop
=
false
;
}
else
{
$loop
=
false
;
}
}
while
(
$loop
);
return
0
;
}
}
\ 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