Documentation ¶
Overview ¶
Used for Herdius Requirements Original Copyright (c) Tendermint Core. https://github.com/tendermint/tendermint/blob/master/LICENSE
Index ¶
- Variables
- func CreateRandSalt(n int) string
- func CreateTxID(txbBeforeSign []byte) string
- func Exit(s string)
- func FileExists(filePath string) bool
- func IsEmpty(o interface{}) bool
- func IsTypedNil(o interface{}) bool
- func MustReadFile(filePath string) []byte
- func PanicCrisis(v interface{})
- func RandBool() bool
- func RandBytes(n int) []byte
- func RandFloat32() float32
- func RandFloat64() float64
- func RandInt() int
- func RandInt16() int16
- func RandInt31() int32
- func RandInt31n(n int32) int32
- func RandInt32() int32
- func RandInt63() int64
- func RandInt63n(n int64) int64
- func RandInt64() int64
- func RandIntn(n int) int
- func RandPerm(n int) []int
- func RandStr(length int) string
- func RandTime() time.Time
- func RandUint() uint
- func RandUint16() uint16
- func RandUint32() uint32
- func RandUint64() uint64
- func ReadFile(filePath string) ([]byte, error)
- func Seed(seed int64)
- func WriteFile(filePath string, contents []byte, mode os.FileMode) error
- type BaseService
- func (bs *BaseService) IsRunning() bool
- func (bs *BaseService) OnReset() error
- func (bs *BaseService) OnStart() error
- func (bs *BaseService) OnStop()
- func (bs *BaseService) Quit() <-chan struct{}
- func (bs *BaseService) Reset() error
- func (bs *BaseService) SetLogger(l log.Logger)
- func (bs *BaseService) Start() error
- func (bs *BaseService) Stop() error
- func (bs *BaseService) String() string
- func (bs *BaseService) Wait()
- type Error
- type FmtError
- type HexBytes
- func (bz HexBytes) Bytes() []byte
- func (bz HexBytes) Format(s fmt.State, verb rune)
- func (bz HexBytes) Marshal() ([]byte, error)
- func (bz HexBytes) MarshalJSON() ([]byte, error)
- func (bz HexBytes) String() string
- func (bz *HexBytes) Unmarshal(data []byte) error
- func (bz *HexBytes) UnmarshalJSON(data []byte) error
- type KVPair
- func (*KVPair) Descriptor() ([]byte, []int)
- func (m *KVPair) GetKey() []byte
- func (m *KVPair) GetValue() []byte
- func (*KVPair) ProtoMessage()
- func (m *KVPair) Reset()
- func (m *KVPair) String() string
- func (m *KVPair) XXX_DiscardUnknown()
- func (m *KVPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *KVPair) XXX_Merge(src proto.Message)
- func (m *KVPair) XXX_Size() int
- func (m *KVPair) XXX_Unmarshal(b []byte) error
- type KVPairs
- type Rand
- func (r *Rand) Bool() bool
- func (r *Rand) Bytes(n int) []byte
- func (r *Rand) Float32() float32
- func (r *Rand) Float64() float64
- func (r *Rand) Int() int
- func (r *Rand) Int16() int16
- func (r *Rand) Int31() int32
- func (r *Rand) Int31n(n int32) int32
- func (r *Rand) Int32() int32
- func (r *Rand) Int63() int64
- func (r *Rand) Int63n(n int64) int64
- func (r *Rand) Int64() int64
- func (r *Rand) Intn(n int) int
- func (r *Rand) Perm(n int) []int
- func (r *Rand) Seed(seed int64)
- func (r *Rand) Str(length int) string
- func (r *Rand) Time() time.Time
- func (r *Rand) Uint() uint
- func (r *Rand) Uint16() uint16
- func (r *Rand) Uint32() uint32
- func (r *Rand) Uint64() uint64
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyStarted is returned when somebody tries to start an already // running service. ErrAlreadyStarted = errors.New("already started") // ErrAlreadyStopped is returned when somebody tries to stop an already // stopped service (without resetting it). ErrAlreadyStopped = errors.New("already stopped") // ErrNotStarted is returned when somebody tries to stop a not running // service. ErrNotStarted = errors.New("not started") )
Functions ¶
func CreateRandSalt ¶
CreateRandSalt - Creates a salt and will be used in creating the keys
func CreateTxID ¶
CreateTxID creates an ID for a given encoded transaction
func IsTypedNil ¶
func IsTypedNil(o interface{}) bool
Go lacks a simple and safe way to see if something is a typed nil. See:
func MustReadFile ¶
func PanicCrisis ¶
func PanicCrisis(v interface{})
PanicCrisis ... A panic here means something has gone horribly wrong, in the form of data corruption or failure of the operating system. In a correct/healthy system, these should never fire. If they do, it's indicative of a much more serious problem.
func RandFloat32 ¶
func RandFloat32() float32
func RandFloat64 ¶
func RandFloat64() float64
func RandInt31n ¶
func RandInt63n ¶
func RandUint16 ¶
func RandUint16() uint16
func RandUint32 ¶
func RandUint32() uint32
func RandUint64 ¶
func RandUint64() uint64
Types ¶
type BaseService ¶
Classical-inheritance-style service declarations. Services can be started, then stopped, then optionally restarted.
Users can override the OnStart/OnStop methods. In the absence of errors, these methods are guaranteed to be called at most once. If OnStart returns an error, service won't be marked as started, so the user can call Start again.
A call to Reset will panic, unless OnReset is overwritten, allowing OnStart/OnStop to be called again.
The caller must ensure that Start and Stop are not called concurrently.
It is ok to call Stop without calling Start first.
Typical usage:
type FooService struct { BaseService // private fields } func NewFooService() *FooService { fs := &FooService{ // init } fs.BaseService = *NewBaseService(log, "FooService", fs) return fs } func (fs *FooService) OnStart() error { fs.BaseService.OnStart() // Always call the overridden method. // initialize private fields // start subroutines, etc. } func (fs *FooService) OnStop() error { fs.BaseService.OnStop() // Always call the overridden method. // close/destroy private fields // stop subroutines, etc. }
func NewBaseService ¶
func NewBaseService(logger log.Logger, name string, impl Service) *BaseService
NewBaseService creates a new BaseService.
func (*BaseService) IsRunning ¶
func (bs *BaseService) IsRunning() bool
IsRunning implements Service by returning true or false depending on the service's state.
func (*BaseService) OnReset ¶
func (bs *BaseService) OnReset() error
OnReset implements Service by panicking.
func (*BaseService) OnStart ¶
func (bs *BaseService) OnStart() error
OnStart implements Service by doing nothing. NOTE: Do not put anything in here, that way users don't need to call BaseService.OnStart()
func (*BaseService) OnStop ¶
func (bs *BaseService) OnStop()
OnStop implements Service by doing nothing. NOTE: Do not put anything in here, that way users don't need to call BaseService.OnStop()
func (*BaseService) Quit ¶
func (bs *BaseService) Quit() <-chan struct{}
Quit Implements Service by returning a quit channel.
func (*BaseService) Reset ¶
func (bs *BaseService) Reset() error
Reset implements Service by calling OnReset callback (if defined). An error will be returned if the service is running.
func (*BaseService) SetLogger ¶
func (bs *BaseService) SetLogger(l log.Logger)
SetLogger implements Service by setting a logger.
func (*BaseService) Start ¶
func (bs *BaseService) Start() error
Start implements Service by calling OnStart (if defined). An error will be returned if the service is already running or stopped. Not to start the stopped service, you need to call Reset.
func (*BaseService) Stop ¶
func (bs *BaseService) Stop() error
Stop implements Service by calling OnStop (if defined) and closing quit channel. An error will be returned if the service is already stopped.
func (*BaseService) String ¶
func (bs *BaseService) String() string
String implements Servce by returning a string representation of the service.
type Error ¶
type Error interface { Error() string Stacktrace() Error Trace(offset int, format string, args ...interface{}) Error Data() interface{} }
Error ...
type HexBytes ¶
type HexBytes []byte
HexBytes : The main purpose of HexBytes is to enable HEX-encoding for json/encoding.
func (HexBytes) Format ¶
Format : HexBytes format using untyped constant against 32-bit integer values
func (HexBytes) MarshalJSON ¶
MarshalJSON : This is the point of Bytes.
func (*HexBytes) UnmarshalJSON ¶
UnmarshalJSON : This is the point of Bytes.
type KVPair ¶
type KVPair struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Define these here for compatibility but use libs/common.KVPair.
func (*KVPair) Descriptor ¶
func (*KVPair) ProtoMessage ¶
func (*KVPair) ProtoMessage()
func (*KVPair) XXX_DiscardUnknown ¶
func (m *KVPair) XXX_DiscardUnknown()
func (*KVPair) XXX_Marshal ¶
func (*KVPair) XXX_Unmarshal ¶
type Rand ¶
Rand is a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however none of the provided methods are suitable for cryptographic usage. They all utilize math/rand's prng internally.
All of the methods here are suitable for concurrent use. This is achieved by using a mutex lock on all of the provided methods.
func (*Rand) Intn ¶
Intn returns, as an int, a uniform pseudo-random number in the range [0, n). It panics if n <= 0.
type Service ¶
type Service interface { // Start the service. // If it's already started or stopped, will return an error. // If OnStart() returns an error, it's returned by Start() Start() error OnStart() error // Stop the service. // If it's already stopped, will return an error. // OnStop must never error. Stop() error OnStop() // Reset the service. // Panics by default - must be overwritten to enable reset. Reset() error OnReset() error // Return true if the service is running IsRunning() bool // Quit returns a channel, which is closed once service is stopped. Quit() <-chan struct{} // String representation of the service String() string // SetLogger sets a logger. SetLogger(log.Logger) }
Service defines a service that can be started, stopped, and reset.