Documentation
¶
Index ¶
- Constants
- func CopyBytes(src []byte) (dst []byte)
- func GenerateRandomBytes() []byte
- type ByTime
- type CustomLogger
- func (logger *CustomLogger) Debug(msg string, ctx ...interface{})
- func (logger *CustomLogger) Error(msg string, ctx ...interface{})
- func (logger *CustomLogger) Info(msg string, ctx ...interface{})
- func (logger *CustomLogger) Trace(msg string, ctx ...interface{})
- func (logger *CustomLogger) Warn(msg string, ctx ...interface{})
- type Event
- type Hash
- type Hashes
- type Logger
- type NullLogger
- func (logger *NullLogger) Debug(msg string, ctx ...interface{})
- func (logger *NullLogger) Error(msg string, ctx ...interface{})
- func (logger *NullLogger) Info(msg string, ctx ...interface{})
- func (logger *NullLogger) Trace(msg string, ctx ...interface{})
- func (logger *NullLogger) Warn(msg string, ctx ...interface{})
- type SimpleLogger
- func (logger *SimpleLogger) Debug(msg string, ctx ...interface{})
- func (logger *SimpleLogger) Error(msg string, ctx ...interface{})
- func (logger *SimpleLogger) Info(msg string, ctx ...interface{})
- func (logger *SimpleLogger) Trace(msg string, ctx ...interface{})
- func (logger *SimpleLogger) Warn(msg string, ctx ...interface{})
- type SortedHashes
Constants ¶
const (
// HashLength is the length of a hash in DEXON.
HashLength = 32
)
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomBytes ¶
func GenerateRandomBytes() []byte
GenerateRandomBytes generates bytes randomly.
Types ¶
type CustomLogger ¶
type CustomLogger struct {
// contains filtered or unexported fields
}
CustomLogger logs everything.
func NewCustomLogger ¶
func NewCustomLogger(logger *log.Logger) *CustomLogger
NewCustomLogger creates a new custom logger.
func (*CustomLogger) Debug ¶
func (logger *CustomLogger) Debug(msg string, ctx ...interface{})
Debug implements Logger interface.
func (*CustomLogger) Error ¶
func (logger *CustomLogger) Error(msg string, ctx ...interface{})
Error implements Logger interface.
func (*CustomLogger) Info ¶
func (logger *CustomLogger) Info(msg string, ctx ...interface{})
Info implements Logger interface.
func (*CustomLogger) Trace ¶
func (logger *CustomLogger) Trace(msg string, ctx ...interface{})
Trace implements Logger interface.
func (*CustomLogger) Warn ¶
func (logger *CustomLogger) Warn(msg string, ctx ...interface{})
Warn implements Logger interface.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event implements the Observer pattern.
func (*Event) NotifyHeight ¶
NotifyHeight and trigger function callback.
func (*Event) RegisterHeight ¶
RegisterHeight to get notified on a specific height.
type Hash ¶
type Hash [HashLength]byte
Hash is the basic hash type in DEXON.
func (Hash) MarshalText ¶
MarshalText implements the encoding.TextMarhsaler interface.
func (*Hash) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Logger ¶
type Logger interface { // Info logs info level logs. Trace(msg string, ctx ...interface{}) Debug(msg string, ctx ...interface{}) Info(msg string, ctx ...interface{}) Warn(msg string, ctx ...interface{}) Error(msg string, ctx ...interface{}) }
Logger define the way to receive logs from Consensus instance. NOTE: parameter in 'ctx' should be paired as key-value mapping. For example,
to log an error with message: logger.Error("some message", "error", err) which is similar to loggers with context: logger.Error("some message", map[string]interface{}{ "error": err, })
type NullLogger ¶
type NullLogger struct{}
NullLogger logs nothing.
func (*NullLogger) Debug ¶
func (logger *NullLogger) Debug(msg string, ctx ...interface{})
Debug implements Logger interface.
func (*NullLogger) Error ¶
func (logger *NullLogger) Error(msg string, ctx ...interface{})
Error implements Logger interface.
func (*NullLogger) Info ¶
func (logger *NullLogger) Info(msg string, ctx ...interface{})
Info implements Logger interface.
func (*NullLogger) Trace ¶
func (logger *NullLogger) Trace(msg string, ctx ...interface{})
Trace implements Logger interface.
func (*NullLogger) Warn ¶
func (logger *NullLogger) Warn(msg string, ctx ...interface{})
Warn implements Logger interface.
type SimpleLogger ¶
type SimpleLogger struct{}
SimpleLogger logs everything.
func (*SimpleLogger) Debug ¶
func (logger *SimpleLogger) Debug(msg string, ctx ...interface{})
Debug implements Logger interface.
func (*SimpleLogger) Error ¶
func (logger *SimpleLogger) Error(msg string, ctx ...interface{})
Error implements Logger interface.
func (*SimpleLogger) Info ¶
func (logger *SimpleLogger) Info(msg string, ctx ...interface{})
Info implements Logger interface.
func (*SimpleLogger) Trace ¶
func (logger *SimpleLogger) Trace(msg string, ctx ...interface{})
Trace implements Logger interface.
func (*SimpleLogger) Warn ¶
func (logger *SimpleLogger) Warn(msg string, ctx ...interface{})
Warn implements Logger interface.
type SortedHashes ¶
type SortedHashes Hashes
SortedHashes is a slice of hashes sorted in ascending order.
func NewSortedHashes ¶
func NewSortedHashes(hs Hashes) SortedHashes
NewSortedHashes converts a slice of hashes to a sorted one. It's a firewall to prevent us from assigning unsorted hashes to a variable declared as SortedHashes directly.