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
3feb38f4
Commit
3feb38f4
authored
Sep 10, 2019
by
mdj33
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decouple mver consens with ticket
parent
dfac9364
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
164 additions
and
131 deletions
+164
-131
chain33.para.toml
chain33.para.toml
+6
-10
chain33.toml
chain33.toml
+13
-7
chain33.test.toml
plugin/consensus/pbft/chain33.test.toml
+0
-12
chain33.test.toml
plugin/consensus/raft/chain33.test.toml
+0
-12
chain33.test.toml
plugin/consensus/tendermint/chain33.test.toml
+0
-12
chain33.cfg.toml
plugin/consensus/ticket/testdata/chain33.cfg.toml
+15
-10
ticket.go
plugin/consensus/ticket/ticket.go
+11
-10
chain33.para.test.toml
plugin/dapp/paracross/cmd/build/chain33.para.test.toml
+6
-10
action.go
plugin/dapp/paracross/executor/action.go
+2
-2
reward.go
plugin/dapp/paracross/executor/reward.go
+2
-2
cfg.go
plugin/dapp/paracross/testnode/cfg.go
+10
-2
chain33.cfg.toml
plugin/dapp/ticket/executor/testdata/chain33.cfg.toml
+16
-7
ticket_test.go
plugin/dapp/ticket/executor/ticket_test.go
+4
-4
ticketdb.go
plugin/dapp/ticket/executor/ticketdb.go
+5
-5
rpc.go
plugin/dapp/ticket/rpc/rpc.go
+1
-1
rpc_test.go
plugin/dapp/ticket/rpc/rpc_test.go
+5
-2
ticket.go
plugin/dapp/ticket/types/ticket.go
+32
-0
ticket.go
plugin/dapp/ticket/wallet/ticket.go
+13
-9
chain33.test.toml
plugin/mempool/price/chain33.test.toml
+12
-7
chain33.test.toml
plugin/mempool/score/chain33.test.toml
+11
-7
No files found.
chain33.para.toml
View file @
3feb38f4
...
@@ -80,18 +80,14 @@ minerExecs=["paracross"] #配置挖矿合约
...
@@ -80,18 +80,14 @@ minerExecs=["paracross"] #配置挖矿合约
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits
=
"0x1f00ffff"
maxTxNumber
=
1600
[mver.consensus.paracross]
coinReward
=
18
coinReward
=
18
coinDevFund
=
12
coinDevFund
=
12
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimePerBlock
=
16
[consensus.sub.para]
[consensus.sub.para]
#主链节点的grpc服务器ip,当前可以支持多ip负载均衡,如“101.37.227.226:8802,39.97.20.242:8802,47.107.15.126:8802,jiedian2.bityuan.com,cloud.bityuan.com”
#主链节点的grpc服务器ip,当前可以支持多ip负载均衡,如“101.37.227.226:8802,39.97.20.242:8802,47.107.15.126:8802,jiedian2.bityuan.com,cloud.bityuan.com”
...
...
chain33.toml
View file @
3feb38f4
...
@@ -90,37 +90,43 @@ minerExecs=["ticket", "autonomy"]
...
@@ -90,37 +90,43 @@ minerExecs=["ticket", "autonomy"]
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits
=
"0x1f00ffff"
maxTxNumber
=
1600
#160
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
1500
[mver.consensus.ForkTicketFundAddrV1]
fundKeyAddr
=
"1Ji3W12KGScCM7C2p8bg635sNkayDM8MGY"
[mver.consensus.ticket]
coinReward
=
18
coinReward
=
18
coinDevFund
=
12
coinDevFund
=
12
ticketPrice
=
10000
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.
ticket.
ForkChainParamV1]
futureBlockTime
=
15
futureBlockTime
=
15
ticketFrozenTime
=
43200
ticketFrozenTime
=
43200
ticketWithdrawTime
=
172800
ticketWithdrawTime
=
172800
ticketMinerWaitTime
=
7200
ticketMinerWaitTime
=
7200
maxTxNumber
=
1500
targetTimespan
=
2160
targetTimespan
=
2160
targetTimePerBlock
=
15
targetTimePerBlock
=
15
[mver.consensus.ForkChainParamV2]
[mver.consensus.
ticket.
ForkChainParamV2]
coinReward
=
5
coinReward
=
5
coinDevFund
=
3
coinDevFund
=
3
targetTimespan
=
720
targetTimespan
=
720
targetTimePerBlock
=
5
targetTimePerBlock
=
5
ticketPrice
=
3000
ticketPrice
=
3000
[mver.consensus.ForkTicketFundAddrV1]
fundKeyAddr
=
"1Ji3W12KGScCM7C2p8bg635sNkayDM8MGY"
[consensus.sub.ticket]
[consensus.sub.ticket]
genesisBlockTime
=
1514533394
genesisBlockTime
=
1514533394
...
...
plugin/consensus/pbft/chain33.test.toml
View file @
3feb38f4
...
@@ -66,23 +66,11 @@ minerstart=false
...
@@ -66,23 +66,11 @@ minerstart=false
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
coinReward
=
18
coinDevFund
=
12
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
powLimitBits
=
"0x1f2fffff"
...
...
plugin/consensus/raft/chain33.test.toml
View file @
3feb38f4
...
@@ -83,23 +83,11 @@ minerstart=false
...
@@ -83,23 +83,11 @@ minerstart=false
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
coinReward
=
18
coinDevFund
=
12
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
powLimitBits
=
"0x1f2fffff"
...
...
plugin/consensus/tendermint/chain33.test.toml
View file @
3feb38f4
...
@@ -70,23 +70,11 @@ minerstart=false
...
@@ -70,23 +70,11 @@ minerstart=false
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
coinReward
=
18
coinDevFund
=
12
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
powLimitBits
=
"0x1f2fffff"
...
...
plugin/consensus/ticket/testdata/chain33.cfg.toml
View file @
3feb38f4
...
@@ -74,30 +74,35 @@ minerExecs=["ticket", "autonomy"]
...
@@ -74,30 +74,35 @@ minerExecs=["ticket", "autonomy"]
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits
=
"0x1f00ffff"
maxTxNumber
=
1600
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
[mver.consensus.ForkTicketFundAddrV1]
fundKeyAddr
=
"1Ji3W12KGScCM7C2p8bg635sNkayDM8MGY"
[mver.consensus.ticket]
coinReward
=
18
coinReward
=
18
coinDevFund
=
12
coinDevFund
=
12
ticketPrice
=
10000
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
futureBlockTime
=
16
ticketFrozenTime
=
5
ticketFrozenTime
=
5
ticketWithdrawTime
=
10
ticketWithdrawTime
=
10
ticketMinerWaitTime
=
2
ticketMinerWaitTime
=
2
maxTxNumber
=
1600
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ticket.ForkChainParamV1]
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
[mver.consensus.ForkTicketFundAddrV1]
fundKeyAddr
=
"1Ji3W12KGScCM7C2p8bg635sNkayDM8MGY"
[consensus.sub.solo]
[consensus.sub.solo]
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesisBlockTime
=
1514533394
genesisBlockTime
=
1514533394
...
...
plugin/consensus/ticket/ticket.go
View file @
3feb38f4
...
@@ -125,7 +125,7 @@ func createTicket(minerAddr, returnAddr string, count int32, height int64) (ret
...
@@ -125,7 +125,7 @@ func createTicket(minerAddr, returnAddr string, count int32, height int64) (ret
tx1
.
To
=
minerAddr
tx1
.
To
=
minerAddr
//gen payload
//gen payload
g
:=
&
cty
.
CoinsAction_Genesis
{}
g
:=
&
cty
.
CoinsAction_Genesis
{}
g
.
Genesis
=
&
types
.
AssetsGenesis
{
Amount
:
ty
pes
.
GetP
(
height
)
.
TicketPrice
}
g
.
Genesis
=
&
types
.
AssetsGenesis
{
Amount
:
ty
.
GetTicketMinerParam
(
height
)
.
TicketPrice
}
tx1
.
Payload
=
types
.
Encode
(
&
cty
.
CoinsAction
{
Value
:
g
,
Ty
:
cty
.
CoinsActionGenesis
})
tx1
.
Payload
=
types
.
Encode
(
&
cty
.
CoinsAction
{
Value
:
g
,
Ty
:
cty
.
CoinsActionGenesis
})
ret
=
append
(
ret
,
&
tx1
)
ret
=
append
(
ret
,
&
tx1
)
...
@@ -135,7 +135,7 @@ func createTicket(minerAddr, returnAddr string, count int32, height int64) (ret
...
@@ -135,7 +135,7 @@ func createTicket(minerAddr, returnAddr string, count int32, height int64) (ret
tx2
.
To
=
driver
.
ExecAddress
(
"ticket"
)
tx2
.
To
=
driver
.
ExecAddress
(
"ticket"
)
//gen payload
//gen payload
g
=
&
cty
.
CoinsAction_Genesis
{}
g
=
&
cty
.
CoinsAction_Genesis
{}
g
.
Genesis
=
&
types
.
AssetsGenesis
{
Amount
:
int64
(
count
)
*
ty
pes
.
GetP
(
height
)
.
TicketPrice
,
ReturnAddress
:
returnAddr
}
g
.
Genesis
=
&
types
.
AssetsGenesis
{
Amount
:
int64
(
count
)
*
ty
.
GetTicketMinerParam
(
height
)
.
TicketPrice
,
ReturnAddress
:
returnAddr
}
tx2
.
Payload
=
types
.
Encode
(
&
cty
.
CoinsAction
{
Value
:
g
,
Ty
:
cty
.
CoinsActionGenesis
})
tx2
.
Payload
=
types
.
Encode
(
&
cty
.
CoinsAction
{
Value
:
g
,
Ty
:
cty
.
CoinsActionGenesis
})
ret
=
append
(
ret
,
&
tx2
)
ret
=
append
(
ret
,
&
tx2
)
...
@@ -307,7 +307,7 @@ func (client *Client) getModify(beg, end int64) ([]byte, error) {
...
@@ -307,7 +307,7 @@ func (client *Client) getModify(beg, end int64) ([]byte, error) {
// CheckBlock ticket implete checkblock func
// CheckBlock ticket implete checkblock func
func
(
client
*
Client
)
CheckBlock
(
parent
*
types
.
Block
,
current
*
types
.
BlockDetail
)
error
{
func
(
client
*
Client
)
CheckBlock
(
parent
*
types
.
Block
,
current
*
types
.
BlockDetail
)
error
{
cfg
:=
ty
pes
.
GetP
(
current
.
Block
.
Height
)
cfg
:=
ty
.
GetTicketMinerParam
(
current
.
Block
.
Height
)
if
current
.
Block
.
BlockTime
-
types
.
Now
()
.
Unix
()
>
cfg
.
FutureBlockTime
{
if
current
.
Block
.
BlockTime
-
types
.
Now
()
.
Unix
()
>
cfg
.
FutureBlockTime
{
return
types
.
ErrFutureBlock
return
types
.
ErrFutureBlock
}
}
...
@@ -444,7 +444,8 @@ func (client *Client) getNextRequiredDifficulty(block *types.Block, bits uint32)
...
@@ -444,7 +444,8 @@ func (client *Client) getNextRequiredDifficulty(block *types.Block, bits uint32)
if
block
==
nil
{
if
block
==
nil
{
return
types
.
GetP
(
0
)
.
PowLimitBits
,
defaultModify
,
nil
return
types
.
GetP
(
0
)
.
PowLimitBits
,
defaultModify
,
nil
}
}
cfg
:=
types
.
GetP
(
block
.
Height
)
powLimitBits
:=
types
.
GetP
(
block
.
Height
)
.
PowLimitBits
cfg
:=
ty
.
GetTicketMinerParam
(
block
.
Height
)
blocksPerRetarget
:=
int64
(
cfg
.
TargetTimespan
/
cfg
.
TargetTimePerBlock
)
blocksPerRetarget
:=
int64
(
cfg
.
TargetTimespan
/
cfg
.
TargetTimePerBlock
)
// Return the previous block's difficulty requirements if this block
// Return the previous block's difficulty requirements if this block
// is not at a difficulty retarget interval.
// is not at a difficulty retarget interval.
...
@@ -462,15 +463,15 @@ func (client *Client) getNextRequiredDifficulty(block *types.Block, bits uint32)
...
@@ -462,15 +463,15 @@ func (client *Client) getNextRequiredDifficulty(block *types.Block, bits uint32)
// worth of blocks).
// worth of blocks).
firstBlock
,
err
:=
client
.
RequestBlock
(
block
.
Height
+
1
-
blocksPerRetarget
)
firstBlock
,
err
:=
client
.
RequestBlock
(
block
.
Height
+
1
-
blocksPerRetarget
)
if
err
!=
nil
{
if
err
!=
nil
{
return
cfg
.
P
owLimitBits
,
defaultModify
,
err
return
p
owLimitBits
,
defaultModify
,
err
}
}
if
firstBlock
==
nil
{
if
firstBlock
==
nil
{
return
cfg
.
P
owLimitBits
,
defaultModify
,
types
.
ErrBlockNotFound
return
p
owLimitBits
,
defaultModify
,
types
.
ErrBlockNotFound
}
}
modify
,
err
:=
client
.
getModify
(
block
.
Height
+
1
-
blocksPerRetarget
,
block
.
Height
)
modify
,
err
:=
client
.
getModify
(
block
.
Height
+
1
-
blocksPerRetarget
,
block
.
Height
)
if
err
!=
nil
{
if
err
!=
nil
{
return
cfg
.
P
owLimitBits
,
defaultModify
,
err
return
p
owLimitBits
,
defaultModify
,
err
}
}
// Limit the amount of adjustment that can occur to the previous
// Limit the amount of adjustment that can occur to the previous
// difficulty.
// difficulty.
...
@@ -496,7 +497,7 @@ func (client *Client) getNextRequiredDifficulty(block *types.Block, bits uint32)
...
@@ -496,7 +497,7 @@ func (client *Client) getNextRequiredDifficulty(block *types.Block, bits uint32)
newTarget
.
Div
(
newTarget
,
big
.
NewInt
(
targetTimespan
))
newTarget
.
Div
(
newTarget
,
big
.
NewInt
(
targetTimespan
))
// Limit new value to the proof of work limit.
// Limit new value to the proof of work limit.
powLimit
:=
difficulty
.
CompactToBig
(
cfg
.
P
owLimitBits
)
powLimit
:=
difficulty
.
CompactToBig
(
p
owLimitBits
)
if
newTarget
.
Cmp
(
powLimit
)
>
0
{
if
newTarget
.
Cmp
(
powLimit
)
>
0
{
newTarget
.
Set
(
powLimit
)
newTarget
.
Set
(
powLimit
)
}
}
...
@@ -542,7 +543,7 @@ func (client *Client) searchTargetTicket(parent, block *types.Block) (*ty.Ticket
...
@@ -542,7 +543,7 @@ func (client *Client) searchTargetTicket(parent, block *types.Block) (*ty.Ticket
continue
continue
}
}
//已经到成熟期
//已经到成熟期
if
!
ticket
.
GetIsGenesis
()
&&
(
block
.
BlockTime
-
ticket
.
GetCreateTime
()
<=
ty
pes
.
GetP
(
block
.
Height
)
.
TicketFrozenTime
)
{
if
!
ticket
.
GetIsGenesis
()
&&
(
block
.
BlockTime
-
ticket
.
GetCreateTime
()
<=
ty
.
GetTicketMinerParam
(
block
.
Height
)
.
TicketFrozenTime
)
{
continue
continue
}
}
// 查找私钥
// 查找私钥
...
@@ -638,7 +639,7 @@ func (client *Client) addMinerTx(parent, block *types.Block, diff *big.Int, priv
...
@@ -638,7 +639,7 @@ func (client *Client) addMinerTx(parent, block *types.Block, diff *big.Int, priv
miner
.
TicketId
=
tid
miner
.
TicketId
=
tid
miner
.
Bits
=
difficulty
.
BigToCompact
(
diff
)
miner
.
Bits
=
difficulty
.
BigToCompact
(
diff
)
miner
.
Modify
=
modify
miner
.
Modify
=
modify
miner
.
Reward
=
ty
pes
.
GetP
(
block
.
Height
)
.
CoinReward
+
fee
miner
.
Reward
=
ty
.
GetTicketMinerParam
(
block
.
Height
)
.
CoinReward
+
fee
privHash
,
err
:=
genPrivHash
(
priv
,
tid
)
privHash
,
err
:=
genPrivHash
(
priv
,
tid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
plugin/dapp/paracross/cmd/build/chain33.para.test.toml
View file @
3feb38f4
...
@@ -76,18 +76,14 @@ minerExecs=["paracross"] #配置挖矿合约
...
@@ -76,18 +76,14 @@ minerExecs=["paracross"] #配置挖矿合约
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
coinReward
=
18
coinDevFund
=
12
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimePerBlock
=
16
[mver.consensus.paracross]
coinReward
=
18
coinDevFund
=
12
[consensus.sub.para]
[consensus.sub.para]
ParaRemoteGrpcClient
=
"localhost:8802"
ParaRemoteGrpcClient
=
"localhost:8802"
...
...
plugin/dapp/paracross/executor/action.go
View file @
3feb38f4
...
@@ -941,8 +941,8 @@ func (a *action) Miner(miner *pt.ParacrossMinerAction) (*types.Receipt, error) {
...
@@ -941,8 +941,8 @@ func (a *action) Miner(miner *pt.ParacrossMinerAction) (*types.Receipt, error) {
if
miner
.
IsSelfConsensus
{
if
miner
.
IsSelfConsensus
{
//增发coins到paracross合约中,只处理发放,不做分配
//增发coins到paracross合约中,只处理发放,不做分配
totalReward
:=
int64
(
0
)
totalReward
:=
int64
(
0
)
coinReward
:=
types
.
MGInt
(
"mver.consensus.coinReward"
,
a
.
height
)
coinReward
:=
types
.
MGInt
(
"mver.consensus.
paracross.
coinReward"
,
a
.
height
)
fundReward
:=
types
.
MGInt
(
"mver.consensus.coinDevFund"
,
a
.
height
)
fundReward
:=
types
.
MGInt
(
"mver.consensus.
paracross.
coinDevFund"
,
a
.
height
)
if
coinReward
>
0
{
if
coinReward
>
0
{
totalReward
+=
coinReward
totalReward
+=
coinReward
...
...
plugin/dapp/paracross/executor/reward.go
View file @
3feb38f4
...
@@ -11,8 +11,8 @@ import (
...
@@ -11,8 +11,8 @@ import (
func
(
a
*
action
)
reward
(
nodeStatus
*
pt
.
ParacrossNodeStatus
,
stat
*
pt
.
ParacrossHeightStatus
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
reward
(
nodeStatus
*
pt
.
ParacrossNodeStatus
,
stat
*
pt
.
ParacrossHeightStatus
)
(
*
types
.
Receipt
,
error
)
{
//获取挖矿相关配置,这里需注意是共识的高度,而不是交易的高度
//获取挖矿相关配置,这里需注意是共识的高度,而不是交易的高度
coinReward
:=
types
.
MGInt
(
"mver.consensus.coinReward"
,
nodeStatus
.
Height
)
*
types
.
Coin
coinReward
:=
types
.
MGInt
(
"mver.consensus.
paracross.
coinReward"
,
nodeStatus
.
Height
)
*
types
.
Coin
fundReward
:=
types
.
MGInt
(
"mver.consensus.coinDevFund"
,
nodeStatus
.
Height
)
*
types
.
Coin
fundReward
:=
types
.
MGInt
(
"mver.consensus.
paracross.
coinDevFund"
,
nodeStatus
.
Height
)
*
types
.
Coin
fundAddr
:=
types
.
MGStr
(
"mver.consensus.fundKeyAddr"
,
nodeStatus
.
Height
)
fundAddr
:=
types
.
MGStr
(
"mver.consensus.fundKeyAddr"
,
nodeStatus
.
Height
)
minerAddrs
:=
getMiners
(
stat
.
Details
,
nodeStatus
.
BlockHash
)
minerAddrs
:=
getMiners
(
stat
.
Details
,
nodeStatus
.
BlockHash
)
...
...
plugin/dapp/paracross/testnode/cfg.go
View file @
3feb38f4
...
@@ -84,19 +84,27 @@ minerExecs=["paracross"]
...
@@ -84,19 +84,27 @@ minerExecs=["paracross"]
[mver.consensus]
[mver.consensus]
fundKeyAddr = "1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr = "1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits = "0x1f00ffff"
maxTxNumber = 1600 #160
[mver.consensus.ticket]
coinReward = 18
coinReward = 18
coinDevFund = 12
coinDevFund = 12
ticketPrice = 10000
ticketPrice = 10000
powLimitBits = "0x1f00ffff"
retargetAdjustmentFactor = 4
retargetAdjustmentFactor = 4
futureBlockTime = 16
futureBlockTime = 16
ticketFrozenTime = 5 #5s only for test
ticketFrozenTime = 5 #5s only for test
ticketWithdrawTime = 10 #10s only for test
ticketWithdrawTime = 10 #10s only for test
ticketMinerWaitTime = 2 #2s only for test
ticketMinerWaitTime = 2 #2s only for test
maxTxNumber = 1600 #160
targetTimespan = 2304
targetTimespan = 2304
targetTimePerBlock = 16
targetTimePerBlock = 16
[mver.consensus.paracross]
coinReward = 18
coinDevFund = 12
[consensus.sub.para]
[consensus.sub.para]
#主链节点的grpc服务器ip,当前可以支持多ip负载均衡,如“101.37.227.226:8802,39.97.20.242:8802,47.107.15.126:8802,jiedian2.33.cn”
#主链节点的grpc服务器ip,当前可以支持多ip负载均衡,如“101.37.227.226:8802,39.97.20.242:8802,47.107.15.126:8802,jiedian2.33.cn”
ParaRemoteGrpcClient=""
ParaRemoteGrpcClient=""
...
...
plugin/dapp/ticket/executor/testdata/chain33.cfg.toml
View file @
3feb38f4
...
@@ -74,32 +74,41 @@ minerExecs=["ticket", "autonomy"]
...
@@ -74,32 +74,41 @@ minerExecs=["ticket", "autonomy"]
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits
=
"0x1f00ffff"
maxTxNumber
=
1600
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
[mver.consensus.ForkChainParamV2]
maxTxNumber
=
1500
powLimitBits
=
"0x1f2fffff"
[mver.consensus.ticket]
coinReward
=
18
coinReward
=
18
coinDevFund
=
12
coinDevFund
=
12
ticketPrice
=
10000
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
futureBlockTime
=
16
ticketFrozenTime
=
5
ticketFrozenTime
=
5
ticketWithdrawTime
=
10
ticketWithdrawTime
=
10
ticketMinerWaitTime
=
2
ticketMinerWaitTime
=
2
maxTxNumber
=
1600
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ticket.ForkChainParamV1]
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
[mver.consensus.
ticket.
ForkChainParamV2]
coinReward
=
5
coinReward
=
5
coinDevFund
=
3
coinDevFund
=
3
ticketPrice
=
3000
ticketPrice
=
3000
maxTxNumber
=
1500
targetTimespan
=
720
targetTimespan
=
720
targetTimePerBlock
=
1
targetTimePerBlock
=
1
powLimitBits
=
"0x1f2fffff"
[mver.consensus.ForkTicketFundAddrV1]
[mver.consensus.ForkTicketFundAddrV1]
fundKeyAddr
=
"1Ji3W12KGScCM7C2p8bg635sNkayDM8MGY"
fundKeyAddr
=
"1Ji3W12KGScCM7C2p8bg635sNkayDM8MGY"
...
...
plugin/dapp/ticket/executor/ticket_test.go
View file @
3feb38f4
...
@@ -42,13 +42,13 @@ func TestTicketPrice(t *testing.T) {
...
@@ -42,13 +42,13 @@ func TestTicketPrice(t *testing.T) {
func
TestCheckFork
(
t
*
testing
.
T
)
{
func
TestCheckFork
(
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
int64
(
1
),
types
.
GetFork
(
"ForkChainParamV2"
))
assert
.
Equal
(
t
,
int64
(
1
),
types
.
GetFork
(
"ForkChainParamV2"
))
p1
:=
ty
pes
.
GetP
(
0
)
p1
:=
ty
.
GetTicketMinerParam
(
0
)
assert
.
Equal
(
t
,
10000
*
types
.
Coin
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
10000
*
types
.
Coin
,
p1
.
TicketPrice
)
p1
=
ty
pes
.
GetP
(
1
)
p1
=
ty
.
GetTicketMinerParam
(
1
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
p1
=
ty
pes
.
GetP
(
2
)
p1
=
ty
.
GetTicketMinerParam
(
2
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
p1
=
ty
pes
.
GetP
(
3
)
p1
=
ty
.
GetTicketMinerParam
(
3
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
}
}
...
...
plugin/dapp/ticket/executor/ticketdb.go
View file @
3feb38f4
...
@@ -37,7 +37,7 @@ type DB struct {
...
@@ -37,7 +37,7 @@ type DB struct {
//GetRealPrice 获取真实的价格
//GetRealPrice 获取真实的价格
func
(
t
*
DB
)
GetRealPrice
()
int64
{
func
(
t
*
DB
)
GetRealPrice
()
int64
{
if
t
.
GetPrice
()
==
0
{
if
t
.
GetPrice
()
==
0
{
cfg
:=
ty
pes
.
GetP
(
types
.
GetFork
(
"ForkChainParamV1"
))
cfg
:=
ty
.
GetTicketMinerParam
(
types
.
GetFork
(
"ForkChainParamV1"
))
return
cfg
.
TicketPrice
return
cfg
.
TicketPrice
}
}
return
t
.
GetPrice
()
return
t
.
GetPrice
()
...
@@ -142,7 +142,7 @@ func (action *Action) GenesisInit(genesis *ty.TicketGenesis) (*types.Receipt, er
...
@@ -142,7 +142,7 @@ func (action *Action) GenesisInit(genesis *ty.TicketGenesis) (*types.Receipt, er
prefix
=
genesis
.
MinerAddress
+
":"
+
prefix
+
":"
prefix
=
genesis
.
MinerAddress
+
":"
+
prefix
+
":"
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
cfg
:=
ty
pes
.
GetP
(
action
.
height
)
cfg
:=
ty
.
GetTicketMinerParam
(
action
.
height
)
for
i
:=
0
;
i
<
int
(
genesis
.
Count
);
i
++
{
for
i
:=
0
;
i
<
int
(
genesis
.
Count
);
i
++
{
id
:=
prefix
+
fmt
.
Sprintf
(
"%010d"
,
i
)
id
:=
prefix
+
fmt
.
Sprintf
(
"%010d"
,
i
)
t
:=
NewDB
(
id
,
genesis
.
MinerAddress
,
genesis
.
ReturnAddress
,
action
.
blocktime
,
action
.
height
,
cfg
.
TicketPrice
,
true
)
t
:=
NewDB
(
id
,
genesis
.
MinerAddress
,
genesis
.
ReturnAddress
,
action
.
blocktime
,
action
.
height
,
cfg
.
TicketPrice
,
true
)
...
@@ -240,7 +240,7 @@ func (action *Action) TicketOpen(topen *ty.TicketOpen) (*types.Receipt, error) {
...
@@ -240,7 +240,7 @@ func (action *Action) TicketOpen(topen *ty.TicketOpen) (*types.Receipt, error) {
}
}
}
}
//action.fromaddr == topen.ReturnAddress or mineraddr == action.fromaddr
//action.fromaddr == topen.ReturnAddress or mineraddr == action.fromaddr
cfg
:=
ty
pes
.
GetP
(
action
.
height
)
cfg
:=
ty
.
GetTicketMinerParam
(
action
.
height
)
for
i
:=
0
;
i
<
int
(
topen
.
Count
);
i
++
{
for
i
:=
0
;
i
<
int
(
topen
.
Count
);
i
++
{
id
:=
prefix
+
fmt
.
Sprintf
(
"%010d"
,
i
)
id
:=
prefix
+
fmt
.
Sprintf
(
"%010d"
,
i
)
//add pubHash
//add pubHash
...
@@ -303,7 +303,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
...
@@ -303,7 +303,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
if
ticket
.
Status
!=
1
{
if
ticket
.
Status
!=
1
{
return
nil
,
types
.
ErrCoinBaseTicketStatus
return
nil
,
types
.
ErrCoinBaseTicketStatus
}
}
cfg
:=
ty
pes
.
GetP
(
action
.
height
)
cfg
:=
ty
.
GetTicketMinerParam
(
action
.
height
)
if
!
ticket
.
IsGenesis
{
if
!
ticket
.
IsGenesis
{
if
action
.
blocktime
-
ticket
.
GetCreateTime
()
<
cfg
.
TicketFrozenTime
{
if
action
.
blocktime
-
ticket
.
GetCreateTime
()
<
cfg
.
TicketFrozenTime
{
return
nil
,
ty
.
ErrTime
return
nil
,
ty
.
ErrTime
...
@@ -370,7 +370,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
...
@@ -370,7 +370,7 @@ func (action *Action) TicketMiner(miner *ty.TicketMiner, index int) (*types.Rece
// TicketClose close tick
// TicketClose close tick
func
(
action
*
Action
)
TicketClose
(
tclose
*
ty
.
TicketClose
)
(
*
types
.
Receipt
,
error
)
{
func
(
action
*
Action
)
TicketClose
(
tclose
*
ty
.
TicketClose
)
(
*
types
.
Receipt
,
error
)
{
tickets
:=
make
([]
*
DB
,
len
(
tclose
.
TicketId
))
tickets
:=
make
([]
*
DB
,
len
(
tclose
.
TicketId
))
cfg
:=
ty
pes
.
GetP
(
action
.
height
)
cfg
:=
ty
.
GetTicketMinerParam
(
action
.
height
)
for
i
:=
0
;
i
<
len
(
tclose
.
TicketId
);
i
++
{
for
i
:=
0
;
i
<
len
(
tclose
.
TicketId
);
i
++
{
ticket
,
err
:=
readTicket
(
action
.
db
,
tclose
.
TicketId
[
i
])
ticket
,
err
:=
readTicket
(
action
.
db
,
tclose
.
TicketId
[
i
])
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/ticket/rpc/rpc.go
View file @
3feb38f4
...
@@ -32,7 +32,7 @@ func (g *channelClient) CreateBindMiner(ctx context.Context, in *ty.ReqBindMiner
...
@@ -32,7 +32,7 @@ func (g *channelClient) CreateBindMiner(ctx context.Context, in *ty.ReqBindMiner
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
in
.
Amount
%
ty
pes
.
GetP
(
header
.
Height
)
.
TicketPrice
!=
0
||
in
.
Amount
<
0
{
if
in
.
Amount
%
ty
.
GetTicketMinerParam
(
header
.
Height
)
.
TicketPrice
!=
0
||
in
.
Amount
<
0
{
return
nil
,
types
.
ErrAmount
return
nil
,
types
.
ErrAmount
}
}
err
=
address
.
CheckAddress
(
in
.
BindAddr
)
err
=
address
.
CheckAddress
(
in
.
BindAddr
)
...
...
plugin/dapp/ticket/rpc/rpc_test.go
View file @
3feb38f4
...
@@ -28,16 +28,19 @@ Title="test"
...
@@ -28,16 +28,19 @@ Title="test"
[mver.consensus]
[mver.consensus]
fundKeyAddr = "1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr = "1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits = "0x1f00ffff"
maxTxNumber = 10000
[mver.consensus.ticket]
coinReward = 18
coinReward = 18
coinDevFund = 12
coinDevFund = 12
ticketPrice = 10000
ticketPrice = 10000
powLimitBits = "0x1f00ffff"
retargetAdjustmentFactor = 4
retargetAdjustmentFactor = 4
futureBlockTime = 16
futureBlockTime = 16
ticketFrozenTime = 5
ticketFrozenTime = 5
ticketWithdrawTime = 10
ticketWithdrawTime = 10
ticketMinerWaitTime = 2
ticketMinerWaitTime = 2
maxTxNumber = 10000
targetTimespan = 2304
targetTimespan = 2304
targetTimePerBlock = 16
targetTimePerBlock = 16
`
`
...
...
plugin/dapp/ticket/types/ticket.go
View file @
3feb38f4
...
@@ -7,6 +7,7 @@ package types
...
@@ -7,6 +7,7 @@ package types
import
(
import
(
"errors"
"errors"
"reflect"
"reflect"
"time"
//log "github.com/33cn/chain33/common/log/log15"
//log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
...
@@ -119,3 +120,34 @@ func (ticket *TicketType) GetTypeMap() map[string]int32 {
...
@@ -119,3 +120,34 @@ func (ticket *TicketType) GetTypeMap() map[string]int32 {
"Miner"
:
TicketActionMiner
,
"Miner"
:
TicketActionMiner
,
}
}
}
}
// TicketMinerParam
type
TicketMinerParam
struct
{
CoinDevFund
int64
CoinReward
int64
FutureBlockTime
int64
TicketPrice
int64
TicketFrozenTime
int64
TicketWithdrawTime
int64
TicketMinerWaitTime
int64
TargetTimespan
time
.
Duration
TargetTimePerBlock
time
.
Duration
RetargetAdjustmentFactor
int64
}
// GetTicketMinerParam 获取ticket miner config params
func
GetTicketMinerParam
(
height
int64
)
*
TicketMinerParam
{
conf
:=
types
.
Conf
(
"mver.consensus.ticket"
)
c
:=
&
TicketMinerParam
{}
c
.
CoinDevFund
=
conf
.
MGInt
(
"coinDevFund"
,
height
)
*
types
.
Coin
c
.
CoinReward
=
conf
.
MGInt
(
"coinReward"
,
height
)
*
types
.
Coin
c
.
FutureBlockTime
=
conf
.
MGInt
(
"futureBlockTime"
,
height
)
c
.
TicketPrice
=
conf
.
MGInt
(
"ticketPrice"
,
height
)
*
types
.
Coin
c
.
TicketFrozenTime
=
conf
.
MGInt
(
"ticketFrozenTime"
,
height
)
c
.
TicketWithdrawTime
=
conf
.
MGInt
(
"ticketWithdrawTime"
,
height
)
c
.
TicketMinerWaitTime
=
conf
.
MGInt
(
"ticketMinerWaitTime"
,
height
)
c
.
TargetTimespan
=
time
.
Duration
(
conf
.
MGInt
(
"targetTimespan"
,
height
))
*
time
.
Second
c
.
TargetTimePerBlock
=
time
.
Duration
(
conf
.
MGInt
(
"targetTimePerBlock"
,
height
))
*
time
.
Second
c
.
RetargetAdjustmentFactor
=
conf
.
MGInt
(
"retargetAdjustmentFactor"
,
height
)
return
c
}
plugin/dapp/ticket/wallet/ticket.go
View file @
3feb38f4
...
@@ -402,15 +402,16 @@ func (policy *ticketPolicy) forceCloseTicketList(height int64, priv crypto.PrivK
...
@@ -402,15 +402,16 @@ func (policy *ticketPolicy) forceCloseTicketList(height int64, priv crypto.PrivK
var
ids
[]
string
var
ids
[]
string
var
tl
[]
*
ty
.
Ticket
var
tl
[]
*
ty
.
Ticket
now
:=
types
.
Now
()
.
Unix
()
now
:=
types
.
Now
()
.
Unix
()
cfg
:=
ty
.
GetTicketMinerParam
(
height
)
for
_
,
t
:=
range
tlist
{
for
_
,
t
:=
range
tlist
{
if
!
t
.
IsGenesis
{
if
!
t
.
IsGenesis
{
if
t
.
Status
==
1
&&
now
-
t
.
GetCreateTime
()
<
types
.
GetP
(
height
)
.
TicketWithdrawTime
{
if
t
.
Status
==
1
&&
now
-
t
.
GetCreateTime
()
<
cfg
.
TicketWithdrawTime
{
continue
continue
}
}
if
t
.
Status
==
2
&&
now
-
t
.
GetCreateTime
()
<
types
.
GetP
(
height
)
.
TicketWithdrawTime
{
if
t
.
Status
==
2
&&
now
-
t
.
GetCreateTime
()
<
cfg
.
TicketWithdrawTime
{
continue
continue
}
}
if
t
.
Status
==
2
&&
now
-
t
.
GetMinerTime
()
<
types
.
GetP
(
height
)
.
TicketMinerWaitTime
{
if
t
.
Status
==
2
&&
now
-
t
.
GetMinerTime
()
<
cfg
.
TicketMinerWaitTime
{
continue
continue
}
}
}
}
...
@@ -495,12 +496,13 @@ func (policy *ticketPolicy) closeTicketsByAddr(height int64, priv crypto.PrivKey
...
@@ -495,12 +496,13 @@ func (policy *ticketPolicy) closeTicketsByAddr(height int64, priv crypto.PrivKey
var
ids
[]
string
var
ids
[]
string
var
tl
[]
*
ty
.
Ticket
var
tl
[]
*
ty
.
Ticket
now
:=
types
.
Now
()
.
Unix
()
now
:=
types
.
Now
()
.
Unix
()
cfg
:=
ty
.
GetTicketMinerParam
(
height
)
for
_
,
t
:=
range
tlist
{
for
_
,
t
:=
range
tlist
{
if
!
t
.
IsGenesis
{
if
!
t
.
IsGenesis
{
if
now
-
t
.
GetCreateTime
()
<
types
.
GetP
(
height
)
.
TicketWithdrawTime
{
if
now
-
t
.
GetCreateTime
()
<
cfg
.
TicketWithdrawTime
{
continue
continue
}
}
if
now
-
t
.
GetMinerTime
()
<
types
.
GetP
(
height
)
.
TicketMinerWaitTime
{
if
now
-
t
.
GetMinerTime
()
<
cfg
.
TicketMinerWaitTime
{
continue
continue
}
}
}
}
...
@@ -633,10 +635,11 @@ func (policy *ticketPolicy) buyTicketOne(height int64, priv crypto.PrivKey) ([]b
...
@@ -633,10 +635,11 @@ func (policy *ticketPolicy) buyTicketOne(height int64, priv crypto.PrivKey) ([]b
}
}
//留一个币作为手续费,如果手续费不够了,不能挖矿
//留一个币作为手续费,如果手续费不够了,不能挖矿
//判断手续费是否足够,如果不足要及时补充。
//判断手续费是否足够,如果不足要及时补充。
cfg
:=
ty
.
GetTicketMinerParam
(
height
)
fee
:=
types
.
Coin
fee
:=
types
.
Coin
if
acc1
.
Balance
+
acc2
.
Balance
-
2
*
fee
>=
types
.
GetP
(
height
)
.
TicketPrice
{
if
acc1
.
Balance
+
acc2
.
Balance
-
2
*
fee
>=
cfg
.
TicketPrice
{
// 如果可用余额+冻结余额,可以凑成新票,则转币到冻结余额
// 如果可用余额+冻结余额,可以凑成新票,则转币到冻结余额
if
(
acc1
.
Balance
+
acc2
.
Balance
-
2
*
fee
)
/
types
.
GetP
(
height
)
.
TicketPrice
>
acc2
.
Balance
/
types
.
GetP
(
height
)
.
TicketPrice
{
if
(
acc1
.
Balance
+
acc2
.
Balance
-
2
*
fee
)
/
cfg
.
TicketPrice
>
acc2
.
Balance
/
cfg
.
TicketPrice
{
//第一步。转移币到 ticket
//第一步。转移币到 ticket
toaddr
:=
address
.
ExecAddress
(
ty
.
TicketX
)
toaddr
:=
address
.
ExecAddress
(
ty
.
TicketX
)
amount
:=
acc1
.
Balance
-
2
*
fee
amount
:=
acc1
.
Balance
-
2
*
fee
...
@@ -657,7 +660,7 @@ func (policy *ticketPolicy) buyTicketOne(height int64, priv crypto.PrivKey) ([]b
...
@@ -657,7 +660,7 @@ func (policy *ticketPolicy) buyTicketOne(height int64, priv crypto.PrivKey) ([]b
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
count
:=
acc
.
Balance
/
types
.
GetP
(
height
)
.
TicketPrice
count
:=
acc
.
Balance
/
cfg
.
TicketPrice
if
count
>
0
{
if
count
>
0
{
txhash
,
err
:=
policy
.
openticket
(
addr
,
addr
,
priv
,
int32
(
count
))
txhash
,
err
:=
policy
.
openticket
(
addr
,
addr
,
priv
,
int32
(
count
))
return
txhash
,
int
(
count
),
err
return
txhash
,
int
(
count
),
err
...
@@ -737,6 +740,7 @@ func (policy *ticketPolicy) buyMinerAddrTicketOne(height int64, priv crypto.Priv
...
@@ -737,6 +740,7 @@ func (policy *ticketPolicy) buyMinerAddrTicketOne(height int64, priv crypto.Priv
}
}
total
:=
0
total
:=
0
var
hashes
[][]
byte
var
hashes
[][]
byte
cfg
:=
ty
.
GetTicketMinerParam
(
height
)
for
i
:=
0
;
i
<
len
(
addrs
);
i
++
{
for
i
:=
0
;
i
<
len
(
addrs
);
i
++
{
bizlog
.
Info
(
"sourceaddr"
,
"addr"
,
addrs
[
i
])
bizlog
.
Info
(
"sourceaddr"
,
"addr"
,
addrs
[
i
])
ok
:=
checkMinerWhiteList
(
addrs
[
i
])
ok
:=
checkMinerWhiteList
(
addrs
[
i
])
...
@@ -748,7 +752,7 @@ func (policy *ticketPolicy) buyMinerAddrTicketOne(height int64, priv crypto.Priv
...
@@ -748,7 +752,7 @@ func (policy *ticketPolicy) buyMinerAddrTicketOne(height int64, priv crypto.Priv
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
count
:=
acc
.
Balance
/
types
.
GetP
(
height
)
.
TicketPrice
count
:=
acc
.
Balance
/
cfg
.
TicketPrice
if
count
>
0
{
if
count
>
0
{
txhash
,
err
:=
policy
.
openticket
(
addr
,
addrs
[
i
],
priv
,
int32
(
count
))
txhash
,
err
:=
policy
.
openticket
(
addr
,
addrs
[
i
],
priv
,
int32
(
count
))
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/mempool/price/chain33.test.toml
View file @
3feb38f4
...
@@ -89,27 +89,32 @@ genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
...
@@ -89,27 +89,32 @@ genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits
=
"0x1f00ffff"
maxTxNumber
=
1600
#160
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
[mver.consensus.ticket]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
coinReward
=
18
coinReward
=
18
coinDevFund
=
12
coinDevFund
=
12
ticketPrice
=
10000
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ticket.ForkChainParamV1]
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
[consensus.sub.solo]
[consensus.sub.solo]
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesisBlockTime
=
1514533394
genesisBlockTime
=
1514533394
...
...
plugin/mempool/score/chain33.test.toml
View file @
3feb38f4
...
@@ -89,27 +89,31 @@ genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
...
@@ -89,27 +89,31 @@ genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits
=
"0x1f00ffff"
maxTxNumber
=
1600
#160
[mver.consensus.ForkChainParamV1]
maxTxNumber
=
10000
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
[mver.consensus.ticket]
coinReward
=
18
coinReward
=
18
coinDevFund
=
12
coinDevFund
=
12
ticketPrice
=
10000
ticketPrice
=
10000
powLimitBits
=
"0x1f00ffff"
retargetAdjustmentFactor
=
4
retargetAdjustmentFactor
=
4
futureBlockTime
=
16
futureBlockTime
=
16
ticketFrozenTime
=
5
#5s only for test
ticketFrozenTime
=
5
#5s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketWithdrawTime
=
10
#10s only for test
ticketMinerWaitTime
=
2
#2s only for test
ticketMinerWaitTime
=
2
#2s only for test
maxTxNumber
=
1600
#160
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[mver.consensus.ForkChainParamV1]
[mver.consensus.ticket.ForkChainParamV1]
maxTxNumber
=
10000
targetTimespan
=
288
#only for test
targetTimespan
=
288
#only for test
targetTimePerBlock
=
2
targetTimePerBlock
=
2
[mver.consensus.ForkChainParamV2]
powLimitBits
=
"0x1f2fffff"
[consensus.sub.solo]
[consensus.sub.solo]
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesisBlockTime
=
1514533394
genesisBlockTime
=
1514533394
...
...
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