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
57a1fe88
Commit
57a1fe88
authored
Dec 10, 2019
by
heyubin
Committed by
vipwzw
Dec 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add by hyb for block-store-intable
parent
ff49b480
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
7 deletions
+36
-7
dpos.go
plugin/consensus/dpos/dpos.go
+6
-2
para.go
plugin/consensus/para/para.go
+1
-1
parasync.go
plugin/consensus/para/parasync.go
+5
-1
block.go
plugin/consensus/pbft/block.go
+5
-1
block.go
plugin/consensus/raft/block.go
+5
-1
consensus_state.go
plugin/consensus/tendermint/consensus_state.go
+8
-1
ticket.go
plugin/consensus/ticket/ticket.go
+6
-0
No files found.
plugin/consensus/dpos/dpos.go
View file @
57a1fe88
...
@@ -465,9 +465,13 @@ func (client *Client) CreateBlock() {
...
@@ -465,9 +465,13 @@ func (client *Client) CreateBlock() {
newblock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newblock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newblock
.
Height
=
lastBlock
.
Height
+
1
newblock
.
Height
=
lastBlock
.
Height
+
1
client
.
AddTxsToBlock
(
&
newblock
,
txs
)
client
.
AddTxsToBlock
(
&
newblock
,
txs
)
//
newblock
.
Difficulty
=
cfg
.
GetP
(
0
)
.
PowLimitBits
newblock
.
Difficulty
=
cfg
.
GetP
(
0
)
.
PowLimitBits
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
//需要首先对交易进行排序然后再计算TxHash
if
cfg
.
IsFork
(
newblock
.
Height
,
"ForkRootHash"
)
{
newblock
.
Txs
=
types
.
TransactionSort
(
newblock
.
Txs
)
}
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
cfg
,
newblock
.
Height
,
newblock
.
Txs
)
newblock
.
BlockTime
=
client
.
blockTime
newblock
.
BlockTime
=
client
.
blockTime
err
:=
client
.
WriteBlock
(
lastBlock
.
StateHash
,
&
newblock
)
err
:=
client
.
WriteBlock
(
lastBlock
.
StateHash
,
&
newblock
)
...
...
plugin/consensus/para/para.go
View file @
57a1fe88
...
@@ -298,7 +298,7 @@ func (client *client) InitBlock() {
...
@@ -298,7 +298,7 @@ func (client *client) InitBlock() {
}
}
tx
:=
client
.
CreateGenesisTx
()
tx
:=
client
.
CreateGenesisTx
()
newblock
.
Txs
=
tx
newblock
.
Txs
=
tx
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
cfg
,
newblock
.
GetMainHeight
(),
newblock
.
Txs
)
err
:=
client
.
blockSyncClient
.
createGenesisBlock
(
newblock
)
err
:=
client
.
blockSyncClient
.
createGenesisBlock
(
newblock
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"para chain create genesis block,err=%s"
,
err
.
Error
()))
panic
(
fmt
.
Sprintf
(
"para chain create genesis block,err=%s"
,
err
.
Error
()))
...
...
plugin/consensus/para/parasync.go
View file @
57a1fe88
...
@@ -403,7 +403,11 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
...
@@ -403,7 +403,11 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
}
}
//挖矿固定难度
//挖矿固定难度
newBlock
.
Difficulty
=
cfg
.
GetP
(
0
)
.
PowLimitBits
newBlock
.
Difficulty
=
cfg
.
GetP
(
0
)
.
PowLimitBits
newBlock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newBlock
.
Txs
)
//需要首先对交易进行排序然后再计算TxHash
if
cfg
.
IsFork
(
newblock
.
GetMainHeight
(),
"ForkRootHash"
)
{
newblock
.
Txs
=
types
.
TransactionSort
(
newblock
.
Txs
)
}
newBlock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
cfg
,
newBlock
.
GetMainHeight
(),
newBlock
.
Txs
)
newBlock
.
BlockTime
=
localBlock
.
BlockTime
newBlock
.
BlockTime
=
localBlock
.
BlockTime
newBlock
.
MainHash
=
localBlock
.
MainHash
newBlock
.
MainHash
=
localBlock
.
MainHash
newBlock
.
MainHeight
=
localBlock
.
MainHeight
newBlock
.
MainHeight
=
localBlock
.
MainHeight
...
...
plugin/consensus/pbft/block.go
View file @
57a1fe88
...
@@ -92,7 +92,11 @@ func (client *Client) CreateBlock() {
...
@@ -92,7 +92,11 @@ func (client *Client) CreateBlock() {
newblock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newblock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newblock
.
Height
=
lastBlock
.
Height
+
1
newblock
.
Height
=
lastBlock
.
Height
+
1
newblock
.
Txs
=
txs
newblock
.
Txs
=
txs
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
//需要首先对交易进行排序
if
cfg
.
IsFork
(
newblock
.
Height
,
"ForkRootHash"
)
{
newblock
.
Txs
=
types
.
TransactionSort
(
newblock
.
Txs
)
}
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
cfg
,
newblock
.
Height
,
newblock
.
Txs
)
newblock
.
BlockTime
=
types
.
Now
()
.
Unix
()
newblock
.
BlockTime
=
types
.
Now
()
.
Unix
()
if
lastBlock
.
BlockTime
>=
newblock
.
BlockTime
{
if
lastBlock
.
BlockTime
>=
newblock
.
BlockTime
{
newblock
.
BlockTime
=
lastBlock
.
BlockTime
+
1
newblock
.
BlockTime
=
lastBlock
.
BlockTime
+
1
...
...
plugin/consensus/raft/block.go
View file @
57a1fe88
...
@@ -184,7 +184,11 @@ func (client *Client) CreateBlock() {
...
@@ -184,7 +184,11 @@ func (client *Client) CreateBlock() {
newblock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newblock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newblock
.
Height
=
lastBlock
.
Height
+
1
newblock
.
Height
=
lastBlock
.
Height
+
1
client
.
AddTxsToBlock
(
&
newblock
,
txs
)
client
.
AddTxsToBlock
(
&
newblock
,
txs
)
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
//需要首先对交易进行排序然后再计算TxHash
if
cfg
.
IsFork
(
newblock
.
Height
,
"ForkRootHash"
)
{
newblock
.
Txs
=
types
.
TransactionSort
(
newblock
.
Txs
)
}
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
cfg
,
newblock
.
Height
,
newblock
.
Txs
)
newblock
.
BlockTime
=
types
.
Now
()
.
Unix
()
newblock
.
BlockTime
=
types
.
Now
()
.
Unix
()
if
lastBlock
.
BlockTime
>=
newblock
.
BlockTime
{
if
lastBlock
.
BlockTime
>=
newblock
.
BlockTime
{
newblock
.
BlockTime
=
lastBlock
.
BlockTime
+
1
newblock
.
BlockTime
=
lastBlock
.
BlockTime
+
1
...
...
plugin/consensus/tendermint/consensus_state.go
View file @
57a1fe88
...
@@ -747,8 +747,15 @@ func (cs *ConsensusState) createProposalBlock() (block *ttypes.TendermintBlock)
...
@@ -747,8 +747,15 @@ func (cs *ConsensusState) createProposalBlock() (block *ttypes.TendermintBlock)
tendermintlog
.
Error
(
"createProposalBlock createBaseTx fail"
)
tendermintlog
.
Error
(
"createProposalBlock createBaseTx fail"
)
return
nil
return
nil
}
}
cfg
:=
cs
.
client
.
GetQueueClient
()
.
GetConfig
()
block
.
Data
.
Txs
[
0
]
=
baseTx
block
.
Data
.
Txs
[
0
]
=
baseTx
block
.
Data
.
TxHash
=
merkle
.
CalcMerkleRoot
(
block
.
Data
.
Txs
)
//需要首先对交易进行排序然后再计算TxHash
if
cfg
.
IsFork
(
block
.
Data
.
Height
,
"ForkRootHash"
)
{
block
.
Data
.
Txs
=
types
.
TransactionSort
(
block
.
Data
.
Txs
)
}
block
.
Data
.
TxHash
=
merkle
.
CalcMerkleRoot
(
cfg
,
block
.
Data
.
Height
,
block
.
Data
.
Txs
)
pblockNew
:=
cs
.
client
.
PreExecBlock
(
block
.
Data
,
false
)
pblockNew
:=
cs
.
client
.
PreExecBlock
(
block
.
Data
,
false
)
if
pblockNew
==
nil
{
if
pblockNew
==
nil
{
tendermintlog
.
Error
(
"createProposalBlock PreExecBlock fail"
)
tendermintlog
.
Error
(
"createProposalBlock PreExecBlock fail"
)
...
...
plugin/consensus/ticket/ticket.go
View file @
57a1fe88
...
@@ -604,6 +604,12 @@ func (client *Client) Miner(parent, block *types.Block) error {
...
@@ -604,6 +604,12 @@ func (client *Client) Miner(parent, block *types.Block) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
//需要首先对交易进行排序
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsFork
(
block
.
Height
,
"ForkRootHash"
)
{
block
.
Txs
=
types
.
TransactionSort
(
block
.
Txs
)
}
err
=
client
.
WriteBlock
(
parent
.
StateHash
,
block
)
err
=
client
.
WriteBlock
(
parent
.
StateHash
,
block
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
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