Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns the default path at which a chaos genesis file is expected
func RegisterValuable ¶
func RegisterValuable(v Valuable)
RegisterValuable registers a Valuable instance
Valuables can only be unmarshalled if they have been registered. It is a good idea to put a bunch of RegisterValuable calls in in an init function in your code in order to be able to unmarshal your types.
Pre-registered types: - address.Address - signature.PublicKey - eai.RTRow
Types ¶
type GFile ¶
GFile represents a genesisfile: a human-friendly representation of the system variables.
func (GFile) IntoSysvars ¶
IntoSysvars converts a GFile into ndau sysvars
type Valuable ¶
type Valuable interface { encoding.TextUnmarshaler encoding.TextMarshaler msgp.Marshaler msgp.Unmarshaler }
Valuable is an interface defining what kind of struct can be represented in the genesisfile.
TextUnmarshaler is required to read the genesisfile. TextMarshaler is required to write the genesisfile. msgp.Marshaler is required to write to the chaos chain. msgp.Unmarshaler is required to read the value from the chaos chain.
type Value ¶
type Value struct { GoType string `toml:"go_type"` Data interface{} `toml:"data"` }
A Value is the innermost type on the chaos chain
GoType must be a string representation of the type of the data. Valid values:
- primitives, in which case `Data` must be of the correct type - `[]byte`, in which case `Data` must be a string the base64-encoded representation - structs which implement `Valuable` - lists of structs which implement `Valuable`
func PackValue ¶
PackValue constructs an appropriate Value from this value.
Value is primarily a text type, dealing with encoded data. PackValue produeces this encoded data as appropriate.
Only certain data types are supported:
- bool, int, int64, uint, uint64, string, time.Time: these types are represented directly in the toml file as native data types
- []byte: represented in the toml file as a base64-encoding
- ndaumath/pkg/types.Ndau, Duration, and Timestamp: these types are represented with appropriate toml primitives
- <type implementing Valuable>: packed with its MarshalText
- []<type implementing Valuable>: packed with its MarshalText
func (Value) IntoBytes ¶
IntoBytes converts this value into a []byte representation.
Only certain data types are supported:
- bool, int, int64, uint, uint64, []byte, string: converted using appropriate wkt encodings - time.Time: written directly in msgPack format - <type implementing msgp.Marshaler>: packed with its MarshalMsg
func (Value) Unpack ¶
Unpack gets the appropriate concrete type from this Value.
Value is primarily a text type, dealing with encoded data. It is normal to wish to deal with raw data. Unpack produeces this.
Only certain data types are supported:
- bool, int, int64, uint, uint64, string, time.Time: these types are represented directly in the toml file as native data types
- []byte: represented in the toml file as a base64-encoding; these are unpacked
- ndaumath/pkg/types.Ndau, Duration, and Timestamp: these types are represented with appropriate toml primitives
- <type implementing Valuable>: unpacked with its UnmarshalText
- []<type implementing Valuable>: unpacked with its UnmarshalText