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
c865ac08
Commit
c865ac08
authored
Oct 10, 2019
by
linj
Committed by
vipwzw
Oct 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fork config tool: 用配置文件格式 打印fork
parent
134189be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
Makefile
Makefile
+1
-0
main.go
cli/fork_config/main.go
+91
-0
No files found.
Makefile
View file @
c865ac08
...
...
@@ -25,6 +25,7 @@ default: depends build
build
:
depends
go build
$(BUILD_FLAGS)
-v
-i
-o
$(APP)
go build
$(BUILD_FLAGS)
-v
-i
-o
$(CLI)
$(SRC_CLI)
go build
$(BUILD_FLAGS)
-v
-i
-o
build/fork-config github.com/33cn/plugin/cli/fork_config/
@
cp
chain33.toml
$(CHAIN33_PATH)
/build/system-test-rpc.sh build/
@
cp
chain33.para.toml build/ci/paracross/
...
...
cli/fork_config/main.go
0 → 100644
View file @
c865ac08
package
main
import
(
"flag"
"fmt"
"os"
"sort"
"strings"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
_
"github.com/33cn/plugin/plugin"
)
var
(
configPath
=
flag
.
String
(
"f"
,
""
,
"configfile"
)
)
func
main
()
{
flag
.
Parse
()
if
*
configPath
==
""
{
*
configPath
=
"chain33.toml"
}
cfg
,
_
:=
types
.
InitCfg
(
*
configPath
)
types
.
Init
(
cfg
.
Title
,
cfg
)
forks
,
err
:=
types
.
CloneFork
(
"chain33"
)
if
err
!=
nil
{
fmt
.
Printf
(
"clone fork failed: %v"
,
err
)
return
}
fmtForks
(
forks
)
}
/*
两个规则:
key 有 ".", Part1.Part2 为 [fork.sub.Part1] Part2=value
key 没有 "." [fork.system] key=value
把相同段的fork打印到一起
[fork.system]
ForkChainParamV1= 0 # ForkBlockCheck=1560000
[fork.sub.ticket]
Enable=0 # manage.ForkManageExec=400000
[fork.sub.store-kvmvccmavl]
ForkKvmvccmavl=2270000 # store-kvmvccmavl.ForkKvmvccmavl=1870000
*/
func
fmtForks
(
forks
map
[
string
]
int64
)
{
systemFork
:=
make
(
map
[
string
]
int64
)
subFork
:=
make
(
map
[
string
]
map
[
string
]
int64
)
for
k
,
v
:=
range
forks
{
if
strings
.
Contains
(
k
,
"."
)
{
str2
:=
strings
.
SplitN
(
k
,
"."
,
2
)
if
len
(
str2
)
!=
2
{
fmt
.
Fprintf
(
os
.
Stderr
,
"can't deal key=%s "
,
k
)
continue
}
_
,
ok
:=
subFork
[
str2
[
0
]]
if
!
ok
{
subFork
[
str2
[
0
]]
=
make
(
map
[
string
]
int64
)
}
subFork
[
str2
[
0
]][
str2
[
1
]]
=
v
}
else
{
systemFork
[
k
]
=
v
}
}
fmt
.
Println
(
"[fork.system]"
)
for
k
,
v
:=
range
systemFork
{
fmt
.
Printf
(
"%s=%d
\n
"
,
k
,
v
)
}
fmt
.
Println
(
""
)
plugins
:=
make
([]
string
,
0
)
for
plugin
:=
range
subFork
{
plugins
=
append
(
plugins
,
plugin
)
}
sort
.
Strings
(
plugins
)
for
_
,
plugin
:=
range
plugins
{
fmt
.
Printf
(
"[fork.sub.%s]
\n
"
,
plugin
)
forks
:=
subFork
[
plugin
]
for
k
,
v
:=
range
forks
{
fmt
.
Printf
(
"%s=%d
\n
"
,
k
,
v
)
}
fmt
.
Println
(
""
)
}
}
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