Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ligaishun
chain33-pai
Commits
60740582
Commit
60740582
authored
Oct 12, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mutx
parent
1b318cf5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
4 deletions
+9
-4
raspberry.sql
docs/sql/raspberry.sql
+2
-1
miner.go
miner/miner.go
+4
-3
raspMinerTxs.go
models/raspMinerTxs.go
+2
-0
pai.go
service/pai_service/pai.go
+1
-0
No files found.
docs/sql/raspberry.sql
View file @
60740582
...
...
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50553
File Encoding : 65001
Date: 2019-10-12 1
0:20:44
Date: 2019-10-12 1
1:11:49
*/
SET
FOREIGN_KEY_CHECKS
=
0
;
...
...
@@ -50,6 +50,7 @@ CREATE TABLE `rasp_miner_stat` (
DROP
TABLE
IF
EXISTS
`rasp_miner_txs`
;
CREATE
TABLE
`rasp_miner_txs`
(
`height`
bigint
(
20
)
NOT
NULL
DEFAULT
'0'
,
`hash`
varchar
(
64
)
NOT
NULL
,
`miner`
varchar
(
64
)
NOT
NULL
,
`return_addr`
varchar
(
64
)
DEFAULT
NULL
,
`amount`
int
(
10
)
DEFAULT
'0'
COMMENT
'矿工挖矿获利'
,
...
...
miner/miner.go
View file @
60740582
...
...
@@ -66,6 +66,7 @@ func SyncBlock() {
txsList
:=
make
([]
*
models
.
RaspMinerTxs
,
0
)
checkList
:=
make
(
map
[
int64
]
int64
,
0
)
var
wg
sync
.
WaitGroup
var
mutx
sync
.
Mutex
for
height
:=
processHeight
;
height
<
processHeight
+
maxDownload
;
height
++
{
wg
.
Add
(
1
)
go
func
(
height
int64
)
{
...
...
@@ -75,13 +76,14 @@ func SyncBlock() {
logging
.
Error
(
"DealBlock err"
,
err
)
panic
(
err
)
}
mutx
.
Lock
()
statList
=
append
(
statList
,
stat
)
txsList
=
append
(
txsList
,
txs
)
mutx
.
Unlock
()
logging
.
Info
(
"DealBlock"
,
height
)
logging
.
Info
(
"DealBlock stat"
,
*
stat
)
logging
.
Info
(
"DealBlock txs"
,
*
txs
)
checkList
[
height
]
=
height
time
.
Sleep
(
time
.
Millisecond
*
10
)
}(
height
)
}
//db.SetMainNetHeight(int(processHeight + types.MaxProcessBlocks + 1))
...
...
@@ -111,7 +113,7 @@ func SyncBlock() {
}
}
if
len
(
txsList
)
!=
int
(
maxDownload
)
||
len
(
txsList
)
!=
len
(
statList
)
{
logging
.
Error
(
"txsList"
,
len
(
txsList
),
"txsMap"
,
len
(
txsMap
),
"statList"
,
len
(
statList
))
logging
.
Error
(
"txsList"
,
len
(
txsList
),
"txsMap"
,
len
(
txsMap
),
"statList"
,
len
(
statList
)
,
"checkList"
,
len
(
checkList
)
)
for
_
,
v
:=
range
checkList
{
var
t
,
s
bool
for
_
,
vv
:=
range
txsList
{
...
...
@@ -159,7 +161,6 @@ func SyncBlock() {
}
func
(
prev
*
prevHeight
)
SetMainHeight
()
error
{
header
,
err
:=
client
.
GetLastHeader
()
...
...
models/raspMinerTxs.go
View file @
60740582
...
...
@@ -10,6 +10,7 @@ type RaspMinerTxs struct {
ReturnAddr
string
`json:"return_addr"`
Amount
int64
`json:"amount"`
Height
int64
`json:"height"`
Hash
string
`json:"hash"`
Time
int64
`json:"time"`
}
...
...
@@ -56,6 +57,7 @@ func AddMinerTxs(data map[string]interface{}) error {
ReturnAddr
:
data
[
"return_addr"
]
.
(
string
),
Amount
:
data
[
"amount"
]
.
(
int64
),
Height
:
data
[
"height"
]
.
(
int64
),
Hash
:
data
[
"hash"
]
.
(
string
),
Time
:
data
[
"time"
]
.
(
int64
),
}
if
err
:=
db
.
Create
(
&
tx
)
.
Error
;
err
!=
nil
{
...
...
service/pai_service/pai.go
View file @
60740582
...
...
@@ -39,6 +39,7 @@ type MinedInfo struct {
type
MinedTxInfo
struct
{
Height
int64
`json:"height"`
Hash
string
`json:"hash"`
Amount
int64
`json:"amount"`
BlockTime
int64
`json:"block_time"`
}
...
...
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