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
334d1b01
Commit
334d1b01
authored
Mar 21, 2020
by
mdj33
Committed by
33cn
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
empty interval
parent
31d287af
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
163 additions
and
55 deletions
+163
-55
chain33.para.toml
chain33.para.toml
+2
-5
para.go
plugin/consensus/para/para.go
+45
-16
para_test.go
plugin/consensus/para/para_test.go
+72
-18
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+21
-10
paracreate.go
plugin/consensus/para/paracreate.go
+12
-3
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+1
-1
paracross.go
plugin/dapp/paracross/commands/paracross.go
+10
-2
No files found.
chain33.para.toml
View file @
334d1b01
...
@@ -103,11 +103,8 @@ mainBlockHashForkHeight=209186
...
@@ -103,11 +103,8 @@ mainBlockHashForkHeight=209186
mainForkParacrossCommitTx
=
2270000
mainForkParacrossCommitTx
=
2270000
#主链开启循环检查共识交易done的fork高度,需要和主链保持严格一致,不可修改,4320000是bityuan主链对应高度, ycc或其他按实际修改
#主链开启循环检查共识交易done的fork高度,需要和主链保持严格一致,不可修改,4320000是bityuan主链对应高度, ycc或其他按实际修改
mainLoopCheckCommitTxDoneForkHeight
=
4320000
mainLoopCheckCommitTxDoneForkHeight
=
4320000
#主链每隔几个没有相关平行链交易的区块,平行链上打包空区块,缺省从平行链blockHeight=0开始,依次增长,空块间隔不能为0
#无平行链交易的主链区块间隔,平行链产生一个空块,从高度0开始,配置[blockHeight:interval],比如["0:50","1000:100"]
[[consensus.sub.para.emptyBlockInterval]]
emptyBlockInterval
=
["0:50"]
blockHeight
=
0
interval
=
50
[store]
[store]
...
...
plugin/consensus/para/para.go
View file @
334d1b01
...
@@ -9,6 +9,8 @@ import (
...
@@ -9,6 +9,8 @@ import (
"fmt"
"fmt"
"sync"
"sync"
"sort"
log
"github.com/33cn/chain33/common/log/log15"
log
"github.com/33cn/chain33/common/log/log15"
"sync/atomic"
"sync/atomic"
...
@@ -62,21 +64,17 @@ type client struct {
...
@@ -62,21 +64,17 @@ type client struct {
minerPrivateKey
crypto
.
PrivKey
minerPrivateKey
crypto
.
PrivKey
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
subCfg
*
subConfig
subCfg
*
subConfig
dldCfg
*
downloadClient
isClosed
int32
isClosed
int32
quitCreate
chan
struct
{}
quitCreate
chan
struct
{}
}
}
type
emptyBlockInterval
struct
{
BlockHeight
int64
`json:"blockHeight,omitempty"`
Interval
int64
`json:"interval,omitempty"`
}
type
subConfig
struct
{
type
subConfig
struct
{
WriteBlockSeconds
int64
`json:"writeBlockSeconds,omitempty"`
WriteBlockSeconds
int64
`json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient,omitempty"`
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient,omitempty"`
StartHeight
int64
`json:"startHeight,omitempty"`
StartHeight
int64
`json:"startHeight,omitempty"`
GenesisStartHeightSame
bool
`json:"genesisStartHeightSame,omitempty"`
GenesisStartHeightSame
bool
`json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval
[]
*
emptyBlockInterval
`json:"emptyBlockInterval,omitempty"`
EmptyBlockInterval
[]
string
`json:"emptyBlockInterval,omitempty"`
AuthAccount
string
`json:"authAccount,omitempty"`
AuthAccount
string
`json:"authAccount,omitempty"`
WaitBlocks4CommitMsg
int32
`json:"waitBlocks4CommitMsg,omitempty"`
WaitBlocks4CommitMsg
int32
`json:"waitBlocks4CommitMsg,omitempty"`
GenesisAmount
int64
`json:"genesisAmount,omitempty"`
GenesisAmount
int64
`json:"genesisAmount,omitempty"`
...
@@ -108,11 +106,12 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -108,11 +106,12 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
if
subcfg
.
WriteBlockSeconds
<=
0
{
if
subcfg
.
WriteBlockSeconds
<=
0
{
subcfg
.
WriteBlockSeconds
=
poolMainBlockSec
subcfg
.
WriteBlockSeconds
=
poolMainBlockSec
}
}
if
len
(
subcfg
.
EmptyBlockInterval
)
==
0
{
interval
:=
&
emptyBlockInterval
{
Interval
:
defaultEmptyBlockInterval
}
emptyInterval
,
err
:=
parseEmptyBlockInterval
(
subcfg
.
EmptyBlockInterval
)
subcfg
.
EmptyBlockInterval
=
append
(
subcfg
.
EmptyBlockInterval
,
interval
)
if
err
!=
nil
{
panic
(
"para EmptyBlockInterval config not correct"
)
}
}
err
:=
checkEmptyBlockInterval
(
subcfg
.
EmptyBlock
Interval
)
err
=
checkEmptyBlockInterval
(
empty
Interval
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"para EmptyBlockInterval config not correct"
)
panic
(
"para EmptyBlockInterval config not correct"
)
}
}
...
@@ -144,6 +143,9 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -144,6 +143,9 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
quitCreate
:
make
(
chan
struct
{}),
quitCreate
:
make
(
chan
struct
{}),
}
}
para
.
dldCfg
=
&
downloadClient
{}
para
.
dldCfg
.
emptyInterval
=
append
(
para
.
dldCfg
.
emptyInterval
,
emptyInterval
...
)
para
.
commitMsgClient
=
&
commitMsgClient
{
para
.
commitMsgClient
=
&
commitMsgClient
{
paraClient
:
para
,
paraClient
:
para
,
authAccount
:
subcfg
.
AuthAccount
,
authAccount
:
subcfg
.
AuthAccount
,
...
@@ -206,18 +208,45 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -206,18 +208,45 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
return
para
return
para
}
}
//["0:50","100:20","500:30"]
func
parseEmptyBlockInterval
(
cfg
[]
string
)
([]
*
emptyBlockInterval
,
error
)
{
var
emptyInter
[]
*
emptyBlockInterval
if
len
(
cfg
)
==
0
{
interval
:=
&
emptyBlockInterval
{
startHeight
:
0
,
interval
:
defaultEmptyBlockInterval
}
emptyInter
=
append
(
emptyInter
,
interval
)
return
emptyInter
,
nil
}
list
:=
make
(
map
[
int64
]
int64
)
var
seq
[]
int64
for
_
,
e
:=
range
cfg
{
ret
,
err
:=
divideStr2Int64s
(
e
,
":"
)
if
err
!=
nil
{
plog
.
Error
(
"parse empty block inter config"
,
"str"
,
e
)
return
nil
,
err
}
seq
=
append
(
seq
,
ret
[
0
])
list
[
ret
[
0
]]
=
ret
[
1
]
}
sort
.
Slice
(
seq
,
func
(
i
,
j
int
)
bool
{
return
seq
[
i
]
<
seq
[
j
]
})
for
_
,
h
:=
range
seq
{
emptyInter
=
append
(
emptyInter
,
&
emptyBlockInterval
{
startHeight
:
h
,
interval
:
list
[
h
]})
}
return
emptyInter
,
nil
}
func
checkEmptyBlockInterval
(
in
[]
*
emptyBlockInterval
)
error
{
func
checkEmptyBlockInterval
(
in
[]
*
emptyBlockInterval
)
error
{
for
i
:=
0
;
i
<
len
(
in
);
i
++
{
for
i
:=
0
;
i
<
len
(
in
);
i
++
{
if
i
==
0
&&
in
[
i
]
.
Block
Height
!=
0
{
if
i
==
0
&&
in
[
i
]
.
start
Height
!=
0
{
plog
.
Error
(
"EmptyBlockInterval,first blockHeight should be 0"
,
"height"
,
in
[
i
]
.
Block
Height
)
plog
.
Error
(
"EmptyBlockInterval,first blockHeight should be 0"
,
"height"
,
in
[
i
]
.
start
Height
)
return
types
.
ErrInvalidParam
return
types
.
ErrInvalidParam
}
}
if
i
>
0
&&
in
[
i
]
.
BlockHeight
<=
in
[
i
-
1
]
.
Block
Height
{
if
i
>
0
&&
in
[
i
]
.
startHeight
<=
in
[
i
-
1
]
.
start
Height
{
plog
.
Error
(
"EmptyBlockInterval,blockHeight should be sequence"
,
"preHeight"
,
in
[
i
-
1
]
.
BlockHeight
,
"laterHeight"
,
in
[
i
]
.
Block
Height
)
plog
.
Error
(
"EmptyBlockInterval,blockHeight should be sequence"
,
"preHeight"
,
in
[
i
-
1
]
.
startHeight
,
"laterHeight"
,
in
[
i
]
.
start
Height
)
return
types
.
ErrInvalidParam
return
types
.
ErrInvalidParam
}
}
if
in
[
i
]
.
I
nterval
<=
0
{
if
in
[
i
]
.
i
nterval
<=
0
{
plog
.
Error
(
"EmptyBlockInterval,interval should > 0"
,
"height"
,
in
[
i
]
.
Block
Height
)
plog
.
Error
(
"EmptyBlockInterval,interval should > 0"
,
"height"
,
in
[
i
]
.
start
Height
)
return
types
.
ErrInvalidParam
return
types
.
ErrInvalidParam
}
}
}
}
...
...
plugin/consensus/para/para_test.go
View file @
334d1b01
...
@@ -225,62 +225,116 @@ func TestGetLastBlockInfo(t *testing.T) {
...
@@ -225,62 +225,116 @@ func TestGetLastBlockInfo(t *testing.T) {
}
}
func
TestGetEmptyInterval
(
t
*
testing
.
T
)
{
func
TestGetEmptyInterval
(
t
*
testing
.
T
)
{
int1
:=
&
emptyBlockInterval
{
BlockHeight
:
0
,
I
nterval
:
1
}
int1
:=
&
emptyBlockInterval
{
startHeight
:
0
,
i
nterval
:
1
}
int2
:=
&
emptyBlockInterval
{
BlockHeight
:
10
,
I
nterval
:
10
}
int2
:=
&
emptyBlockInterval
{
startHeight
:
10
,
i
nterval
:
10
}
int3
:=
&
emptyBlockInterval
{
BlockHeight
:
15
,
I
nterval
:
15
}
int3
:=
&
emptyBlockInterval
{
startHeight
:
15
,
i
nterval
:
15
}
ints
:=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
ints
:=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
para
:=
new
(
client
)
para
:=
new
(
client
)
para
.
subCfg
=
&
subConfig
{
EmptyBlockInterval
:
ints
}
para
.
dldCfg
=
&
downloadClient
{}
para
.
dldCfg
.
emptyInterval
=
append
(
para
.
dldCfg
.
emptyInterval
,
ints
...
)
lastBlock
:=
&
pt
.
ParaLocalDbBlock
{
Height
:
1
}
lastBlock
:=
&
pt
.
ParaLocalDbBlock
{
Height
:
1
}
ret
:=
para
.
getEmptyInterval
(
lastBlock
)
ret
:=
para
.
getEmptyInterval
(
lastBlock
)
assert
.
Equal
(
t
,
int1
.
I
nterval
,
ret
)
assert
.
Equal
(
t
,
int1
.
i
nterval
,
ret
)
lastBlock
=
&
pt
.
ParaLocalDbBlock
{
Height
:
10
}
lastBlock
=
&
pt
.
ParaLocalDbBlock
{
Height
:
10
}
ret
=
para
.
getEmptyInterval
(
lastBlock
)
ret
=
para
.
getEmptyInterval
(
lastBlock
)
assert
.
Equal
(
t
,
int2
.
I
nterval
,
ret
)
assert
.
Equal
(
t
,
int2
.
i
nterval
,
ret
)
lastBlock
=
&
pt
.
ParaLocalDbBlock
{
Height
:
11
}
lastBlock
=
&
pt
.
ParaLocalDbBlock
{
Height
:
11
}
ret
=
para
.
getEmptyInterval
(
lastBlock
)
ret
=
para
.
getEmptyInterval
(
lastBlock
)
assert
.
Equal
(
t
,
int2
.
I
nterval
,
ret
)
assert
.
Equal
(
t
,
int2
.
i
nterval
,
ret
)
lastBlock
=
&
pt
.
ParaLocalDbBlock
{
Height
:
16
}
lastBlock
=
&
pt
.
ParaLocalDbBlock
{
Height
:
16
}
ret
=
para
.
getEmptyInterval
(
lastBlock
)
ret
=
para
.
getEmptyInterval
(
lastBlock
)
assert
.
Equal
(
t
,
int3
.
I
nterval
,
ret
)
assert
.
Equal
(
t
,
int3
.
i
nterval
,
ret
)
}
}
func
TestCheckEmptyInterval
(
t
*
testing
.
T
)
{
func
TestCheckEmptyInterval
(
t
*
testing
.
T
)
{
int1
:=
&
emptyBlockInterval
{
BlockHeight
:
0
,
I
nterval
:
1
}
int1
:=
&
emptyBlockInterval
{
startHeight
:
0
,
i
nterval
:
1
}
int2
:=
&
emptyBlockInterval
{
BlockHeight
:
10
,
I
nterval
:
10
}
int2
:=
&
emptyBlockInterval
{
startHeight
:
10
,
i
nterval
:
10
}
int3
:=
&
emptyBlockInterval
{
BlockHeight
:
15
,
I
nterval
:
15
}
int3
:=
&
emptyBlockInterval
{
startHeight
:
15
,
i
nterval
:
15
}
int1
.
Block
Height
=
5
int1
.
start
Height
=
5
ints
:=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
ints
:=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
err
:=
checkEmptyBlockInterval
(
ints
)
err
:=
checkEmptyBlockInterval
(
ints
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
int1
.
Block
Height
=
0
int1
.
start
Height
=
0
int3
.
Block
Height
=
5
int3
.
start
Height
=
5
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
err
=
checkEmptyBlockInterval
(
ints
)
err
=
checkEmptyBlockInterval
(
ints
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
int3
.
Block
Height
=
10
int3
.
start
Height
=
10
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
err
=
checkEmptyBlockInterval
(
ints
)
err
=
checkEmptyBlockInterval
(
ints
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
int3
.
Block
Height
=
15
int3
.
start
Height
=
15
int2
.
I
nterval
=
0
int2
.
i
nterval
=
0
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
err
=
checkEmptyBlockInterval
(
ints
)
err
=
checkEmptyBlockInterval
(
ints
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
assert
.
Equal
(
t
,
types
.
ErrInvalidParam
,
err
)
int2
.
I
nterval
=
2
int2
.
i
nterval
=
2
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
ints
=
[]
*
emptyBlockInterval
{
int1
,
int2
,
int3
}
err
=
checkEmptyBlockInterval
(
ints
)
err
=
checkEmptyBlockInterval
(
ints
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
nil
,
err
)
}
}
func
TestParseEmptyBlockInterval
(
t
*
testing
.
T
)
{
cfg
:=
[]
string
{}
ret
,
err
:=
parseEmptyBlockInterval
(
cfg
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
0
),
ret
[
0
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
defaultEmptyBlockInterval
),
ret
[
0
]
.
interval
)
cfg
=
[]
string
{
"0:50"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
0
),
ret
[
0
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
defaultEmptyBlockInterval
),
ret
[
0
]
.
interval
)
cfg
=
[]
string
{
"0:50"
,
"100:20"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
0
),
ret
[
0
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
defaultEmptyBlockInterval
),
ret
[
0
]
.
interval
)
assert
.
Equal
(
t
,
int64
(
100
),
ret
[
1
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
20
),
ret
[
1
]
.
interval
)
cfg
=
[]
string
{
"10:50"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
10
),
ret
[
0
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
defaultEmptyBlockInterval
),
ret
[
0
]
.
interval
)
cfg
=
[]
string
{
"10:50"
,
"20-30"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
NotNil
(
t
,
err
)
cfg
=
[]
string
{
"10:50"
,
"20:"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
NotNil
(
t
,
err
)
cfg
=
[]
string
{
"10:50"
,
":20"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
NotNil
(
t
,
err
)
//mess sequence
cfg
=
[]
string
{
"100:30"
,
"0:50"
,
"30:20"
,
"200:10"
}
ret
,
err
=
parseEmptyBlockInterval
(
cfg
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
0
),
ret
[
0
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
defaultEmptyBlockInterval
),
ret
[
0
]
.
interval
)
assert
.
Equal
(
t
,
int64
(
30
),
ret
[
1
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
20
),
ret
[
1
]
.
interval
)
assert
.
Equal
(
t
,
int64
(
100
),
ret
[
2
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
30
),
ret
[
2
]
.
interval
)
assert
.
Equal
(
t
,
int64
(
200
),
ret
[
3
]
.
startHeight
)
assert
.
Equal
(
t
,
int64
(
10
),
ret
[
3
]
.
interval
)
}
plugin/consensus/para/paracommitmsg.go
View file @
334d1b01
...
@@ -907,24 +907,35 @@ func (client *commitMsgClient) fetchPriKey() error {
...
@@ -907,24 +907,35 @@ func (client *commitMsgClient) fetchPriKey() error {
}
}
func
parseSelfConsEnableStr
(
selfEnables
[]
string
)
([]
*
paraSelfConsEnable
,
error
)
{
func
parseSelfConsEnableStr
(
selfEnables
[]
string
)
([]
*
paraSelfConsEnable
,
error
)
{
var
err
error
var
list
[]
*
paraSelfConsEnable
var
list
[]
*
paraSelfConsEnable
for
_
,
v
:=
range
selfEnables
{
for
_
,
e
:=
range
selfEnables
{
hs
:=
strings
.
Split
(
v
,
"-"
)
ret
,
err
:=
divideStr2Int64s
(
e
,
"-"
)
enable
:=
&
paraSelfConsEnable
{}
enable
.
startHeight
,
err
=
strconv
.
ParseInt
(
hs
[
0
],
0
,
64
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"para setSelfConsEnable"
,
"v0"
,
hs
[
0
],
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
enable
.
endHeight
,
err
=
strconv
.
ParseInt
(
hs
[
1
],
0
,
64
)
list
=
append
(
list
,
&
paraSelfConsEnable
{
ret
[
0
],
ret
[
1
]})
}
return
list
,
nil
}
//only for "0:50" or "0-50" with one sep
func
divideStr2Int64s
(
s
,
sep
string
)
([]
int64
,
error
)
{
var
r
[]
int64
a
:=
strings
.
Split
(
s
,
sep
)
if
len
(
a
)
!=
2
{
plog
.
Error
(
"error format for config to seperate"
,
"s"
,
s
)
return
nil
,
types
.
ErrInvalidParam
}
for
_
,
v
:=
range
a
{
val
,
err
:=
strconv
.
ParseInt
(
v
,
0
,
64
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"
para setSelfConsEnable"
,
"v1"
,
hs
[
1
],
"err"
,
err
)
plog
.
Error
(
"
error format for config to parse to int"
,
"s"
,
s
)
return
nil
,
err
return
nil
,
err
}
}
list
=
append
(
list
,
enable
)
r
=
append
(
r
,
val
)
}
}
return
list
,
nil
return
r
,
nil
}
}
func
(
client
*
commitMsgClient
)
setSelfConsEnable
()
error
{
func
(
client
*
commitMsgClient
)
setSelfConsEnable
()
error
{
...
...
plugin/consensus/para/paracreate.go
View file @
334d1b01
...
@@ -21,6 +21,15 @@ import (
...
@@ -21,6 +21,15 @@ import (
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
)
)
type
emptyBlockInterval
struct
{
startHeight
int64
interval
int64
}
type
downloadClient
struct
{
emptyInterval
[]
*
emptyBlockInterval
}
func
(
client
*
client
)
createLocalGenesisBlock
(
genesis
*
types
.
Block
)
error
{
func
(
client
*
client
)
createLocalGenesisBlock
(
genesis
*
types
.
Block
)
error
{
return
client
.
alignLocalBlock2ChainBlock
(
genesis
)
return
client
.
alignLocalBlock2ChainBlock
(
genesis
)
}
}
...
@@ -236,7 +245,7 @@ func (client *client) getBatchSeqCount(currSeq int64) (int64, error) {
...
@@ -236,7 +245,7 @@ func (client *client) getBatchSeqCount(currSeq int64) (int64, error) {
}
}
if
lastSeq
>
currSeq
{
if
lastSeq
>
currSeq
{
if
lastSeq
-
currSeq
>
client
.
subCfg
.
EmptyBlockInterval
[
0
]
.
I
nterval
{
if
lastSeq
-
currSeq
>
client
.
dldCfg
.
emptyInterval
[
0
]
.
i
nterval
{
atomic
.
StoreInt32
(
&
client
.
caughtUp
,
0
)
atomic
.
StoreInt32
(
&
client
.
caughtUp
,
0
)
}
else
{
}
else
{
atomic
.
StoreInt32
(
&
client
.
caughtUp
,
1
)
atomic
.
StoreInt32
(
&
client
.
caughtUp
,
1
)
...
@@ -378,8 +387,8 @@ func (client *client) processHashNotMatchError(currSeq int64, lastSeqMainHash []
...
@@ -378,8 +387,8 @@ func (client *client) processHashNotMatchError(currSeq int64, lastSeqMainHash []
func
(
client
*
client
)
getEmptyInterval
(
lastBlock
*
pt
.
ParaLocalDbBlock
)
int64
{
func
(
client
*
client
)
getEmptyInterval
(
lastBlock
*
pt
.
ParaLocalDbBlock
)
int64
{
for
i
:=
len
(
client
.
subCfg
.
EmptyBlockInterval
)
-
1
;
i
>=
0
;
i
--
{
for
i
:=
len
(
client
.
subCfg
.
EmptyBlockInterval
)
-
1
;
i
>=
0
;
i
--
{
if
lastBlock
.
Height
>=
client
.
subCfg
.
EmptyBlockInterval
[
i
]
.
Block
Height
{
if
lastBlock
.
Height
>=
client
.
dldCfg
.
emptyInterval
[
i
]
.
start
Height
{
return
client
.
subCfg
.
EmptyBlockInterval
[
i
]
.
I
nterval
return
client
.
dldCfg
.
emptyInterval
[
i
]
.
i
nterval
}
}
}
}
panic
(
fmt
.
Sprintf
(
"emptyBlockInterval not set for height=%d"
,
lastBlock
.
Height
))
panic
(
fmt
.
Sprintf
(
"emptyBlockInterval not set for height=%d"
,
lastBlock
.
Height
))
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
334d1b01
...
@@ -42,7 +42,7 @@ function para_set_toml() {
...
@@ -42,7 +42,7 @@ function para_set_toml() {
sed
-i
$xsedfix
's/^Title.*/Title="user.p.'''
"
$paraname
"
'''."/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^Title.*/Title="user.p.'''
"
$paraname
"
'''."/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^# TestNet=.*/TestNet=true/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^# TestNet=.*/TestNet=true/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^startHeight=.*/startHeight=1/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^startHeight=.*/startHeight=1/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^
interval=.*/interval=4
/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^
emptyBlockInterval=.*/emptyBlockInterval=["0:4"]
/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^mainForkParacrossCommitTx=.*/mainForkParacrossCommitTx=10/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^mainForkParacrossCommitTx=.*/mainForkParacrossCommitTx=10/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^mainLoopCheckCommitTxDoneForkHeight=.*/mainLoopCheckCommitTxDoneForkHeight='''
$MainLoopCheckForkHeight
'''/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^mainLoopCheckCommitTxDoneForkHeight=.*/mainLoopCheckCommitTxDoneForkHeight='''
$MainLoopCheckForkHeight
'''/g'
"
${
1
}
"
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
334d1b01
...
@@ -299,8 +299,16 @@ func createCrossAssetTransfer(cmd *cobra.Command, args []string) {
...
@@ -299,8 +299,16 @@ func createCrossAssetTransfer(cmd *cobra.Command, args []string) {
}
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.CreateTransaction"
,
params
,
nil
)
var
res
string
ctx
.
RunWithoutMarshal
()
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.CreateTransaction"
,
params
,
&
res
)
_
,
err
:=
ctx
.
RunResult
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
}
//remove 0x
fmt
.
Println
(
res
[
2
:
])
}
}
func
superNodeCmd
()
*
cobra
.
Command
{
func
superNodeCmd
()
*
cobra
.
Command
{
...
...
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