Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
34688ac3
Commit
34688ac3
authored
8 years ago
by
zramsay
Browse files
Options
Downloads
Patches
Plain Diff
small tweaks to ease use as a library
parent
dc3afdf6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/cmd/genesis.go
+7
-2
7 additions, 2 deletions
client/cmd/genesis.go
genesis/make_genesis_file.go
+7
-9
7 additions, 9 deletions
genesis/make_genesis_file.go
with
14 additions
and
11 deletions
client/cmd/genesis.go
+
7
−
2
View file @
34688ac3
package
commands
package
commands
import
(
import
(
"fmt"
"github.com/eris-ltd/eris-db/genesis"
"github.com/eris-ltd/eris-db/genesis"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
...
@@ -25,8 +27,11 @@ var GenesisGenCmd = &cobra.Command{
...
@@ -25,8 +27,11 @@ var GenesisGenCmd = &cobra.Command{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
genesis
.
GenerateKnown
(
args
[
0
],
AccountsPathFlag
,
ValidatorsPathFlag
)
genesisFile
,
err
:=
genesis
.
GenerateKnown
(
args
[
0
],
AccountsPathFlag
,
ValidatorsPathFlag
)
if
err
!=
nil
{
panic
(
err
)
}
fmt
.
Println
(
genesisFile
)
// may want to save somewhere instead
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
genesis/make_genesis_file.go
+
7
−
9
View file @
34688ac3
...
@@ -20,23 +20,23 @@ import (
...
@@ -20,23 +20,23 @@ import (
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
// core functions
// core functions
func
GenerateKnown
(
chainID
,
accountsPathCSV
,
validatorsPathCSV
string
)
error
{
func
GenerateKnown
(
chainID
,
accountsPathCSV
,
validatorsPathCSV
string
)
(
string
,
error
)
{
var
genDoc
*
stypes
.
GenesisDoc
var
genDoc
*
stypes
.
GenesisDoc
// TODO [eb] eliminate reading priv_val ... [zr] where?
// TODO [eb] eliminate reading priv_val ... [zr] where?
if
accountsPathCSV
==
""
||
validatorsPathCSV
==
""
{
if
accountsPathCSV
==
""
||
validatorsPathCSV
==
""
{
return
fmt
.
Errorf
(
"both accounts.csv and validators.csv is required"
)
return
""
,
fmt
.
Errorf
(
"both accounts.csv and validators.csv is required"
)
}
}
pubkeys
,
amts
,
names
,
perms
,
setbits
,
err
:=
parseCsv
(
validatorsPathCSV
)
pubkeys
,
amts
,
names
,
perms
,
setbits
,
err
:=
parseCsv
(
validatorsPathCSV
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
""
,
err
}
}
pubkeysA
,
amtsA
,
namesA
,
permsA
,
setbitsA
,
err
:=
parseCsv
(
accountsPathCSV
)
pubkeysA
,
amtsA
,
namesA
,
permsA
,
setbitsA
,
err
:=
parseCsv
(
accountsPathCSV
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
""
,
err
}
}
genDoc
=
newGenDoc
(
chainID
,
len
(
pubkeys
),
len
(
pubkeysA
))
genDoc
=
newGenDoc
(
chainID
,
len
(
pubkeys
),
len
(
pubkeysA
))
...
@@ -50,15 +50,13 @@ func GenerateKnown(chainID, accountsPathCSV, validatorsPathCSV string) error {
...
@@ -50,15 +50,13 @@ func GenerateKnown(chainID, accountsPathCSV, validatorsPathCSV string) error {
buf
,
buf2
,
n
:=
new
(
bytes
.
Buffer
),
new
(
bytes
.
Buffer
),
new
(
int
)
buf
,
buf2
,
n
:=
new
(
bytes
.
Buffer
),
new
(
bytes
.
Buffer
),
new
(
int
)
wire
.
WriteJSON
(
genDoc
,
buf
,
n
,
&
err
)
wire
.
WriteJSON
(
genDoc
,
buf
,
n
,
&
err
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
""
,
err
}
}
if
err
:=
json
.
Indent
(
buf2
,
buf
.
Bytes
(),
""
,
"
\t
"
);
err
!=
nil
{
if
err
:=
json
.
Indent
(
buf2
,
buf
.
Bytes
(),
""
,
"
\t
"
);
err
!=
nil
{
return
err
return
""
,
err
}
}
genesisString
:=
buf2
.
String
()
fmt
.
Println
(
genesisString
)
return
nil
return
buf2
.
String
(),
nil
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment