Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar-client-chain33
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
link33
sidecar-client-chain33
Commits
5dbec4c6
Commit
5dbec4c6
authored
May 05, 2022
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sync step control
parent
6b15b917
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
6 deletions
+38
-6
chain33.toml
config/chain33.toml
+1
-0
config.go
config/config.go
+1
-0
evmxgo.go
evmxgo/evmxgo.go
+15
-4
evmxgo.toml
evmxgo/evmxgo.toml
+1
-0
paracross.go
paracross/paracross.go
+12
-2
paracross.toml
paracross/paracross.toml
+1
-0
paracross_test.go
paracross/paracross_test.go
+7
-0
No files found.
config/chain33.toml
View file @
5dbec4c6
...
@@ -8,6 +8,7 @@ start_height = 1
...
@@ -8,6 +8,7 @@ start_height = 1
height_diff
=
0
height_diff
=
0
fee
=
100000
fee
=
100000
is_test
=
true
is_test
=
true
step
=
10
[log]
[log]
level
=
"debug"
level
=
"debug"
...
...
config/config.go
View file @
5dbec4c6
...
@@ -44,6 +44,7 @@ type Chain33 struct {
...
@@ -44,6 +44,7 @@ type Chain33 struct {
StartHeight
int64
`mapstructure:"start_height" json:"start_height"`
// 起始高度
StartHeight
int64
`mapstructure:"start_height" json:"start_height"`
// 起始高度
HeightDiff
int64
`mapstructure:"height_diff" json:"height_diff"`
// 高度差
HeightDiff
int64
`mapstructure:"height_diff" json:"height_diff"`
// 高度差
Fee
int64
`mapstructure:"Fee" json:"Fee"`
// 单笔交易的手续费
Fee
int64
`mapstructure:"Fee" json:"Fee"`
// 单笔交易的手续费
Step
int64
`mapstructure:"step" json:"step"`
// 步长
EventFilter
string
`mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
EventFilter
string
`mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
TimeoutHeight
int64
`mapstructure:"timeout_height" json:"timeout_height"`
TimeoutHeight
int64
`mapstructure:"timeout_height" json:"timeout_height"`
IsTest
bool
`mapstructure:"is_test" json:"is_test"`
IsTest
bool
`mapstructure:"is_test" json:"is_test"`
...
...
evmxgo/evmxgo.go
View file @
5dbec4c6
...
@@ -56,6 +56,8 @@ type Evmxgo struct {
...
@@ -56,6 +56,8 @@ type Evmxgo struct {
height
*
atomic
.
Int64
// 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置
height
*
atomic
.
Int64
// 已经解析的高度。1、初始化时设置; 2、服务每次重启后设置
db
*
util
.
KVDBList
// 记录已完成的hashID、高度等信息。
db
*
util
.
KVDBList
// 记录已完成的hashID、高度等信息。
fee
int64
fee
int64
step
int64
heightDiff
int64
// 高度差
logger
hclog
.
InterceptLogger
logger
hclog
.
InterceptLogger
}
}
...
@@ -171,6 +173,11 @@ func (e *Evmxgo) Initialize(configPath string, _ string, _ []byte) error {
...
@@ -171,6 +173,11 @@ func (e *Evmxgo) Initialize(configPath string, _ string, _ []byte) error {
}
}
e
.
logger
.
Info
(
"startHeight "
,
"startHeight"
,
startHeight
)
e
.
logger
.
Info
(
"startHeight "
,
"startHeight"
,
startHeight
)
e
.
logger
.
Info
(
"latest height"
,
"height"
,
e
.
height
.
Load
())
e
.
logger
.
Info
(
"latest height"
,
"height"
,
e
.
height
.
Load
())
e
.
heightDiff
=
chain33Config
.
Chain33
.
HeightDiff
e
.
step
=
chain33Config
.
Chain33
.
Step
if
e
.
step
==
0
{
e
.
step
=
10
}
// 启动定时器,检查是否有遗漏的数据。
// 启动定时器,检查是否有遗漏的数据。
// 检验已经完成的数据。
// 检验已经完成的数据。
...
@@ -208,16 +215,20 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
...
@@ -208,16 +215,20 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
header
,
err
:=
e
.
client
.
QueryLastHeader
()
header
,
err
:=
e
.
client
.
QueryLastHeader
()
if
err
!=
nil
{
if
err
!=
nil
{
e
.
logger
.
Error
(
"call QueryLastHeader "
,
"error"
,
err
)
e
.
logger
.
Error
(
"call QueryLastHeader "
,
"error"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
//
time.Sleep(2 * time.Second)
}
else
{
}
else
{
e
.
logger
.
Info
(
"GetLastHeader"
,
"height"
,
header
.
Height
)
e
.
logger
.
Info
(
"GetLastHeader"
,
"height"
,
header
.
Height
)
lastHeight
:=
header
.
Height
lastHeight
:=
header
.
Height
height
:=
e
.
height
.
Load
()
height
:=
e
.
height
.
Load
()
if
lastHeight
<=
height
{
if
lastHeight
-
e
.
heightDiff
<=
height
{
time
.
Sleep
(
2
*
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
}
else
{
}
else
{
height1
:=
height
+
1
start
:=
height
+
1
blockInfo
,
err
:=
e
.
client
.
QueryBlockInfo
(
height1
,
height1
,
true
)
end
:=
height
+
1
if
start
+
e
.
step
<=
lastHeight
{
end
=
start
+
e
.
step
}
blockInfo
,
err
:=
e
.
client
.
QueryBlockInfo
(
start
,
end
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
e
.
logger
.
Error
(
"call QueryBlockInfo"
,
"error"
,
err
)
e
.
logger
.
Error
(
"call QueryBlockInfo"
,
"error"
,
err
)
}
else
{
}
else
{
...
...
evmxgo/evmxgo.toml
View file @
5dbec4c6
...
@@ -11,6 +11,7 @@ height_diff = 0
...
@@ -11,6 +11,7 @@ height_diff = 0
fee
=
100000
fee
=
100000
#被监听链ID
#被监听链ID
chain_id
=
0
chain_id
=
0
step
=
10
[log]
[log]
#日志级别
#日志级别
...
...
paracross/paracross.go
View file @
5dbec4c6
...
@@ -68,6 +68,7 @@ type Paracross struct {
...
@@ -68,6 +68,7 @@ type Paracross struct {
// 分类块中的交易为:已完成、未完成的交易。
// 分类块中的交易为:已完成、未完成的交易。
notify
chan
int64
// 高度完成提醒
notify
chan
int64
// 高度完成提醒
heightDiff
int64
// 高度差
heightDiff
int64
// 高度差
step
int64
isTest
bool
isTest
bool
logger
hclog
.
InterceptLogger
logger
hclog
.
InterceptLogger
...
@@ -209,6 +210,10 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error
...
@@ -209,6 +210,10 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error
p
.
logger
.
Info
(
"latest height"
,
"height"
,
p
.
height
.
Load
())
p
.
logger
.
Info
(
"latest height"
,
"height"
,
p
.
height
.
Load
())
p
.
chEvent
=
make
(
chan
*
types
.
Event
,
1
)
p
.
chEvent
=
make
(
chan
*
types
.
Event
,
1
)
p
.
step
=
chain33Config
.
Chain33
.
Step
if
p
.
step
==
0
{
p
.
step
=
10
}
// 启动定时器,检查是否有遗漏的数据。
// 启动定时器,检查是否有遗漏的数据。
...
@@ -234,7 +239,7 @@ func (p *Paracross) pollAppchain() {
...
@@ -234,7 +239,7 @@ func (p *Paracross) pollAppchain() {
header
,
err
:=
p
.
grpcClient
.
GetLastHeader
(
p
.
ctx
,
&
types33
.
ReqNil
{})
header
,
err
:=
p
.
grpcClient
.
GetLastHeader
(
p
.
ctx
,
&
types33
.
ReqNil
{})
if
err
!=
nil
{
if
err
!=
nil
{
p
.
logger
.
Error
(
"GetLastHeader call error"
,
"error"
,
err
)
p
.
logger
.
Error
(
"GetLastHeader call error"
,
"error"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
//
time.Sleep(2 * time.Second)
}
else
{
}
else
{
p
.
logger
.
Info
(
"GetLastHeader"
,
"height"
,
header
.
Height
)
p
.
logger
.
Info
(
"GetLastHeader"
,
"height"
,
header
.
Height
)
lastHeight
:=
header
.
Height
lastHeight
:=
header
.
Height
...
@@ -242,7 +247,12 @@ func (p *Paracross) pollAppchain() {
...
@@ -242,7 +247,12 @@ func (p *Paracross) pollAppchain() {
if
lastHeight
-
p
.
heightDiff
<=
height
{
if
lastHeight
-
p
.
heightDiff
<=
height
{
time
.
Sleep
(
2
*
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
}
else
{
}
else
{
p
.
processBlock
(
height
+
1
,
height
+
1
)
start
:=
height
+
1
end
:=
height
+
1
if
start
+
p
.
step
<=
lastHeight
{
end
=
start
+
p
.
step
}
p
.
processBlock
(
start
,
end
)
}
}
}
}
}
}
...
...
paracross/paracross.toml
View file @
5dbec4c6
...
@@ -13,6 +13,7 @@ height_diff = 6
...
@@ -13,6 +13,7 @@ height_diff = 6
fee
=
100000
fee
=
100000
#被监听链ID
#被监听链ID
chain_id
=
0
chain_id
=
0
step
=
10
[log]
[log]
#日志级别
#日志级别
...
...
paracross/paracross_test.go
View file @
5dbec4c6
...
@@ -4,6 +4,8 @@ import (
...
@@ -4,6 +4,8 @@ import (
"fmt"
"fmt"
"testing"
"testing"
"github.com/33cn/chain33/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
)
...
@@ -19,3 +21,8 @@ func TestMock(t *testing.T) {
...
@@ -19,3 +21,8 @@ func TestMock(t *testing.T) {
fmt
.
Println
(
ibtp
)
fmt
.
Println
(
ibtp
)
}
}
}
}
func
TestHash
(
t
*
testing
.
T
)
{
paraBlockHash
:=
common
.
Sha256
([]
byte
(
"111064"
))
t
.
Log
(
common
.
HashHex
(
paraBlockHash
))
}
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