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
66de9f2c
Commit
66de9f2c
authored
Apr 27, 2022
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix log func
parent
cb3e7668
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
25 deletions
+47
-25
config.go
config/config.go
+4
-1
evmxgo.go
evmxgo/evmxgo.go
+21
-12
go.mod
go.mod
+0
-0
go.sum
go.sum
+0
-0
paracross.go
paracross/paracross.go
+22
-12
No files found.
config/config.go
View file @
66de9f2c
...
...
@@ -13,7 +13,10 @@ type Config struct {
}
type
Log
struct
{
Level
string
`mapstructure:"level" json:"level"`
// NoLevel:0, trace:1, debug:2, info:3, warn:4, error:5, off:6
Dir
string
`toml:"dir" json:"dir"`
Filename
string
`mapstructure:"filename" json:"filename"`
ReportCaller
bool
`mapstructure:"report_caller"`
Level
string
`mapstructure:"level" json:"level"`
// NoLevel:0, trace:1, debug:2, info:3, warn:4, error:5, off:6
}
type
Router
struct
{
...
...
evmxgo/evmxgo.go
View file @
66de9f2c
...
...
@@ -4,20 +4,20 @@ import (
"encoding/json"
"errors"
"fmt"
"
os
"
"
path/filepath
"
"time"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/db"
types33
"github.com/33cn/chain33/types"
evmxgotypes
"github.com/33cn/plugin/plugin/dapp/evmxgo/types"
"github.com/hashicorp/go-hclog"
"github.com/spf13/cast"
"gitlab.33.cn/link33/sidecar-client-chain33/client/rpc"
"gitlab.33.cn/link33/sidecar-client-chain33/config"
"gitlab.33.cn/link33/sidecar-client-chain33/types"
"gitlab.33.cn/link33/sidecar-client-chain33/util"
"gitlab.33.cn/link33/sidecar/model/pb"
"gitlab.33.cn/link33/sidecar/pkg/log"
"gitlab.33.cn/link33/sidecar/pkg/plugins"
"go.uber.org/atomic"
)
...
...
@@ -36,11 +36,7 @@ var (
PluginName
=
evmxgotypes
.
EvmxgoX
ID
=
evmxgotypes
.
EvmxgoX
execer
=
evmxgotypes
.
EvmxgoX
logger
=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
Name
:
"chain33-client-"
+
PluginName
,
Output
:
os
.
Stderr
,
Level
:
hclog
.
Trace
,
})
logger
=
log
.
NewWithModule
(
"chain33-client-"
+
PluginName
)
)
type
Evmxgo
struct
{
...
...
@@ -95,14 +91,28 @@ func (e *Evmxgo) ID() string {
// configPath 完整路径
func
(
e
*
Evmxgo
)
Initialize
(
configPath
string
,
_
string
,
_
[]
byte
)
error
{
// 初始化e.client工作
e
.
eventC
=
make
(
chan
*
pb
.
IBTP
,
10
)
e
.
done
=
make
(
chan
bool
)
e
.
ticker
=
time
.
NewTicker
(
2
*
time
.
Second
)
chain33Config
,
err
:=
config
.
UnmarshalConfig
(
configPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal config for plugin :%w"
,
err
)
}
err
=
log
.
Initialize
(
log
.
WithReportCaller
(
chain33Config
.
Log
.
ReportCaller
==
true
),
log
.
WithPersist
(
true
),
log
.
WithFilePath
(
filepath
.
Join
(
filepath
.
Dir
(
configPath
),
"logs"
,
"evmxgo.log"
)),
log
.
WithFileName
(
"chain33-client-"
+
PluginName
),
log
.
WithMaxSize
(
2
*
1024
*
1024
),
log
.
WithMaxAge
(
24
*
time
.
Hour
),
log
.
WithRotationTime
(
24
*
time
.
Hour
),
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"log initialize: %w"
,
err
)
}
log
.
ParseLevel
(
chain33Config
.
Log
.
Level
)
// 初始化e.client工作
e
.
eventC
=
make
(
chan
*
pb
.
IBTP
,
10
)
e
.
done
=
make
(
chan
bool
)
e
.
ticker
=
time
.
NewTicker
(
2
*
time
.
Second
)
logger
.
Info
(
"print chain33Config"
,
"chain33Config"
,
util
.
Sprint
(
chain33Config
))
logger
.
Info
(
"print privateKey"
,
"privateKey"
,
chain33Config
.
Chain33
.
PrivateKey
)
e
.
pk
=
chain33Config
.
Chain33
.
PrivateKey
...
...
@@ -110,7 +120,6 @@ func (e *Evmxgo) Initialize(configPath string, _ string, _ []byte) error {
e
.
fromID
=
chain33Config
.
Router
.
FromChain
e
.
toID
=
chain33Config
.
Router
.
ToChain
e
.
fee
=
chain33Config
.
Chain33
.
Fee
logger
.
SetLevel
(
hclog
.
LevelFromString
(
chain33Config
.
Log
.
Level
))
// 初始化chain33 client rpc
client
,
err
:=
rpc
.
NewClient
(
""
,
chain33Config
.
Chain33
.
Addr
)
...
...
go.mod
View file @
66de9f2c
This diff is collapsed.
Click to expand it.
go.sum
View file @
66de9f2c
This diff is collapsed.
Click to expand it.
paracross/paracross.go
View file @
66de9f2c
...
...
@@ -8,9 +8,11 @@ import (
"fmt"
"math/big"
"math/rand"
"
os
"
"
path/filepath
"
"time"
"gitlab.33.cn/link33/sidecar/pkg/log"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
...
...
@@ -20,7 +22,6 @@ import (
util33
"github.com/33cn/chain33/util"
"github.com/33cn/plugin/plugin/dapp/paracross/executor"
paracorssTypes
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/hashicorp/go-hclog"
"github.com/spf13/cast"
"gitlab.33.cn/link33/sidecar-client-chain33/config"
"gitlab.33.cn/link33/sidecar-client-chain33/types"
...
...
@@ -35,11 +36,7 @@ var (
PluginName
=
paracorssTypes
.
ParaX
ID
=
paracorssTypes
.
ParaX
execer
=
paracorssTypes
.
ParaX
logger
=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
Name
:
"chain33-client-"
+
PluginName
,
Output
:
os
.
Stderr
,
Level
:
hclog
.
Trace
,
})
logger
=
log
.
NewWithModule
(
"chain33-client-"
+
PluginName
)
)
type
Paracross
struct
{
...
...
@@ -115,14 +112,28 @@ func (p *Paracross) ID() string {
}
func
(
p
*
Paracross
)
Initialize
(
configPath
string
,
ID
string
,
extra
[]
byte
)
error
{
// 初始化e.client工作
p
.
eventC
=
make
(
chan
*
pb
.
IBTP
,
10
)
p
.
done
=
make
(
chan
bool
)
p
.
ticker
=
time
.
NewTicker
(
2
*
time
.
Second
)
chain33Config
,
err
:=
config
.
UnmarshalConfig
(
configPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal config for plugin :%w"
,
err
)
}
err
=
log
.
Initialize
(
log
.
WithReportCaller
(
chain33Config
.
Log
.
ReportCaller
==
true
),
log
.
WithPersist
(
true
),
log
.
WithFilePath
(
filepath
.
Join
(
filepath
.
Dir
(
configPath
),
"logs"
,
"paracross.log"
)),
log
.
WithFileName
(
"chain33-client-"
+
PluginName
),
log
.
WithMaxSize
(
2
*
1024
*
1024
),
log
.
WithMaxAge
(
24
*
time
.
Hour
),
log
.
WithRotationTime
(
24
*
time
.
Hour
),
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"log initialize: %w"
,
err
)
}
log
.
ParseLevel
(
chain33Config
.
Log
.
Level
)
// 初始化e.client工作
p
.
eventC
=
make
(
chan
*
pb
.
IBTP
,
10
)
p
.
done
=
make
(
chan
bool
)
p
.
ticker
=
time
.
NewTicker
(
2
*
time
.
Second
)
logger
.
Info
(
"print chain33Config"
,
"chain33Config"
,
util
.
Sprint
(
chain33Config
))
logger
.
Info
(
"print privateKey"
,
"privateKey"
,
chain33Config
.
Chain33
.
PrivateKey
)
p
.
privateKey
=
util33
.
HexToPrivkey
(
chain33Config
.
Chain33
.
PrivateKey
)
...
...
@@ -132,7 +143,6 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error
p
.
title
=
chain33Config
.
Chain33
.
Title
p
.
MinTxFeeRate
=
chain33Config
.
Chain33
.
Fee
p
.
isTest
=
chain33Config
.
Chain33
.
IsTest
logger
.
SetLevel
(
hclog
.
LevelFromString
(
chain33Config
.
Log
.
Level
))
config33
=
fmt
.
Sprintf
(
config33
,
p
.
title
,
chain33Config
.
Chain33
.
Addr
)
logger
.
Info
(
config33
)
...
...
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