-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ceff6e8
commit ee68028
Showing
4 changed files
with
143 additions
and
20 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,42 @@ | ||
package fault | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"time" | ||
) | ||
|
||
type Mode int | ||
|
||
const ( | ||
Honest = iota | ||
Byzantine | ||
IntervalByzantine | ||
) | ||
|
||
// Behavior represents a system actor return behavior within a L2 (e.g, sequencer, challenger, etc) | ||
type Behavior struct { | ||
Mode Mode `json:"mode"` | ||
Interval time.Duration `json:"interval"` // only used for IntervalByzantine | ||
} | ||
|
||
type Config struct { | ||
Actors map[string]Behavior | ||
} | ||
|
||
func LoadConfig(path string) (*Config, error) { | ||
jsonFile, err := os.Open(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer jsonFile.Close() | ||
|
||
var config Config | ||
err = json.NewDecoder(jsonFile).Decode(&config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &config, nil | ||
} |
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