-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from 0chain/initialState
Initial state
- Loading branch information
Showing
8 changed files
with
88 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package state | ||
|
||
import ( | ||
"0chain.net/core/datastore" | ||
|
||
"gopkg.in/yaml.v2" | ||
"io/ioutil" | ||
) | ||
|
||
// InitStates is a slice of InitState used for all the initial states in the genesis block. | ||
type InitStates struct { | ||
States []InitState `yaml:"initialStates"` | ||
} | ||
|
||
// InitState is a clients initial state in the genesis block. | ||
type InitState struct { | ||
ID datastore.Key `yaml:"id"` | ||
Tokens Balance `yaml:"tokens"` | ||
} | ||
|
||
// NewInitStates is used to return a new InitStates. | ||
func NewInitStates() *InitStates { | ||
return &InitStates{} | ||
} | ||
|
||
// Read is use on the InitStates to read the initial states for the genesis block from a yaml file. | ||
func (initStates *InitStates) Read(file string) (err error) { | ||
bytes, err := ioutil.ReadFile(file) | ||
if err != nil { | ||
return | ||
} | ||
err = yaml.Unmarshal(bytes, initStates) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
initialStates: | ||
- id: 31810bd1258ae95955fb40c7ef72498a556d3587121376d9059119d280f34929 | ||
tokens: 10000000000 | ||
|
||
- id: 585732eb076d07455fbebcf3388856b6fd00449a25c47c0f72d961c7c4e7e7c2 | ||
tokens: 10000000000 | ||
|
||
- id: 8877e3da19b4cb51e59b4646ec7c0cf4849bc7b860257d69ddbf753b9a981e1b | ||
tokens: 10000000000 | ||
|
||
- id: bfa64c67f49bceec8be618b1b6f558bdbaf9c100fd95d55601fa2190a4e548d8 | ||
tokens: 10000000000 | ||
|
||
- id: 57b416fcda1cf82b8a7e1fc3a47c68a94e617be873b5383ea2606bda757d3ce4 | ||
tokens: 10000000000 |