Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
exchain
nebula
Commits
18d934a3
Commit
18d934a3
authored
Mar 25, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update genesis sorted alloc asserts
parent
b799c26c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
16 deletions
+22
-16
gen_genesis_account.go
exchain/genesis/gen_genesis_account.go
+18
-13
genesis.go
exchain/genesis/genesis.go
+4
-3
No files found.
exchain/genesis/gen_genesis_account.go
View file @
18d934a3
...
...
@@ -9,25 +9,27 @@ import (
// MarshalJSON marshals as JSON.
func
(
g
GenesisAccount
)
MarshalJSON
()
([]
byte
,
error
)
{
type
InnerWalletInfo
struct
{
Coin
string
`json:"coin"`
Balance
*
hexutil
.
Big
`json:"balance"`
}
type
GenesisAccount
struct
{
SignerProxy
*
hexutil
.
Bytes
`json:"signerProxy,omitempty"`
Assets
map
[
string
]
InnerWalletInfo
`json:"assets"`
SignerProxy
*
hexutil
.
Bytes
`json:"signerProxy,omitempty"`
Assets
[
]
InnerWalletInfo
`json:"assets"`
}
var
enc
GenesisAccount
if
len
(
g
.
SingerProxy
)
>
0
{
enc
.
SignerProxy
=
(
*
hexutil
.
Bytes
)(
&
g
.
SingerProxy
)
}
enc
.
Assets
=
make
(
map
[
string
]
InnerWalletInfo
,
len
(
g
.
Assets
))
for
k
,
v
:=
range
g
.
Assets
{
wallet
:=
InnerWalletInfo
{}
enc
.
Assets
=
make
([]
InnerWalletInfo
,
0
,
len
(
g
.
Assets
))
for
_
,
v
:=
range
g
.
Assets
{
wallet
:=
InnerWalletInfo
{
Coin
:
v
.
Coin
,
}
if
v
.
Balance
!=
nil
{
balance
:=
hexutil
.
Big
(
*
v
.
Balance
)
wallet
.
Balance
=
&
balance
}
enc
.
Assets
[
k
]
=
wallet
enc
.
Assets
=
append
(
enc
.
Assets
,
wallet
)
}
return
json
.
Marshal
(
&
enc
)
}
...
...
@@ -35,11 +37,12 @@ func (g GenesisAccount) MarshalJSON() ([]byte, error) {
// UnmarshalJSON unmarshals from JSON.
func
(
g
*
GenesisAccount
)
UnmarshalJSON
(
input
[]
byte
)
error
{
type
InnerWalletInfo
struct
{
Coin
string
`json:"coin"`
Balance
*
hexutil
.
Big
`json:"balance"`
}
type
GenesisAccount
struct
{
SignerProxy
*
hexutil
.
Bytes
`json:"signerProxy,omitempty"`
Assets
map
[
string
]
InnerWalletInfo
`json:"assets"`
SignerProxy
*
hexutil
.
Bytes
`json:"signerProxy,omitempty"`
Assets
[
]
InnerWalletInfo
`json:"assets"`
}
var
dec
GenesisAccount
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
...
...
@@ -50,13 +53,15 @@ func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
}
if
dec
.
Assets
!=
nil
{
g
.
Assets
=
make
(
map
[
string
]
WalletInfo
,
len
(
dec
.
Assets
))
for
coin
,
v
:=
range
dec
.
Assets
{
wallet
:=
WalletInfo
{}
g
.
Assets
=
make
([]
WalletInfo
,
0
,
len
(
dec
.
Assets
))
for
_
,
v
:=
range
dec
.
Assets
{
wallet
:=
WalletInfo
{
Coin
:
v
.
Coin
,
}
if
v
.
Balance
!=
nil
{
wallet
.
Balance
=
new
(
big
.
Int
)
.
Set
(
v
.
Balance
.
ToInt
())
}
g
.
Assets
[
coin
]
=
wallet
g
.
Assets
=
append
(
g
.
Assets
,
wallet
)
}
}
return
nil
...
...
exchain/genesis/genesis.go
View file @
18d934a3
...
...
@@ -22,10 +22,11 @@ var (
)
type
WalletInfo
struct
{
Coin
string
`json:"coin"`
Balance
*
big
.
Int
`json:"balance"`
}
type
AssetsInfo
map
[
string
]
WalletInfo
type
AssetsInfo
[
]
WalletInfo
type
GenesisAccount
struct
{
SingerProxy
[]
byte
`json:"signerProxy"`
...
...
@@ -118,7 +119,7 @@ func (g *GenesisBlock) ToBlock() *nebulav1.Block {
}
blk
.
Transactions
.
Txs
=
append
(
blk
.
Transactions
.
Txs
,
tx
)
}
for
asset
,
wallet
:=
range
info
.
Assets
{
for
_
,
wallet
:=
range
info
.
Assets
{
if
wallet
.
Balance
.
Cmp
(
big
.
NewInt
(
0
))
>
0
{
tx
:=
&
nebulav1
.
Transaction
{
TxType
:
nebulav1
.
TxType_DepositTx
,
...
...
@@ -129,7 +130,7 @@ func (g *GenesisBlock) ToBlock() *nebulav1.Block {
DepositTx
:
&
nebulav1
.
DepositTransaction
{
SourceHash
:
common
.
Hash
{}
.
Bytes
(),
User
:
account
.
Bytes
(),
Coin
:
[]
byte
(
asset
),
Coin
:
[]
byte
(
wallet
.
Coin
),
Amount
:
wallet
.
Balance
.
Bytes
(),
},
},
...
...
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