Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
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
link33
plugin
Commits
914e819d
Commit
914e819d
authored
Apr 16, 2019
by
袁兴强
Committed by
vipwzw
Apr 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket data race bug
parent
52413d6f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
ticket.go
plugin/consensus/ticket/ticket.go
+11
-7
No files found.
plugin/consensus/ticket/ticket.go
View file @
914e819d
...
...
@@ -5,6 +5,7 @@
package
ticket
import
(
"errors"
"fmt"
"math/big"
"strconv"
...
...
@@ -530,7 +531,7 @@ func (client *Client) delTicket(ticketID string) {
}
// Miner ticket miner function
func
(
client
*
Client
)
Miner
(
parent
,
block
*
types
.
Block
)
bool
{
func
(
client
*
Client
)
Miner
(
parent
,
block
*
types
.
Block
)
error
{
//add miner address
ticket
,
priv
,
diff
,
modify
,
ticketID
,
err
:=
client
.
searchTargetTicket
(
parent
,
block
)
if
err
!=
nil
{
...
...
@@ -540,21 +541,21 @@ func (client *Client) Miner(parent, block *types.Block) bool {
tlog
.
Error
(
"Miner.RequestLastBlock"
,
"err"
,
err
)
}
client
.
SetCurrentBlock
(
newblock
)
return
false
return
err
}
if
ticket
==
nil
{
return
false
return
errors
.
New
(
"ticket is nil"
)
}
err
=
client
.
addMinerTx
(
parent
,
block
,
diff
,
priv
,
ticket
.
TicketId
,
modify
)
if
err
!=
nil
{
return
false
return
err
}
err
=
client
.
WriteBlock
(
parent
.
StateHash
,
block
)
if
err
!=
nil
{
return
false
return
err
}
client
.
delTicket
(
ticketID
)
return
true
return
nil
}
//gas 直接燃烧
...
...
@@ -687,7 +688,10 @@ func (client *Client) CreateBlock() {
}
block
,
lastBlock
:=
client
.
createBlock
()
hashlist
:=
getTxHashes
(
block
.
Txs
)
for
!
client
.
Miner
(
lastBlock
,
block
)
{
for
err
:=
client
.
Miner
(
lastBlock
,
block
);
err
!=
nil
;
err
=
client
.
Miner
(
lastBlock
,
block
)
{
if
err
==
queue
.
ErrIsQueueClosed
{
break
}
//加入新的txs, 继续挖矿
lasttime
:=
block
.
BlockTime
//只有时间增加了1s影响,影响难度计算了,才会去更新区块
...
...
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