util

package
v0.0.0-...-e8d7442 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONSENSUS_TIME_LEDGER = 0x01
	CONSENSUS_TIME_RAFT   = 0x02
)
View Source
const (
	// Each EPOCH is 30 seconds
	POODLE_EPOCH_MILLIS = 30 * 1000

	DEFAULT_DRIFT_MILLIS_LOW  = 300
	DEFAULT_DRIFT_MILLIS_HIGH = 500

	DEFAULT_ETC_DIR = "/etc/poodle"
	DEFAULT_LIB_DIR = "/var/lib/poodle"
	DEFAULT_LOG_DIR = "/var/log/poodle"

	DEFAULT_SECRET = "poodle"

	DEFAULT_PUDP_PORT = 31415
	DEFAULT_QUIC_PORT = 31416

	MAX_KEY_LENGTH    = 4 * 1024    // Maximum  4 KB Key Length
	MAX_VALUE_LENGTH  = 56 * 1024   // Maximum 56 KB Value Length
	MAX_SCHEME_LENGTH = 1 * 1024    // Maximum  1 KB Scheme Length
	MAX_ATTR_GROUPS   = 256         // maximum 256 Attribute Groups per Key
	MAX_DATA_LENGTH   = 64*1024 - 1 // Maximum 64 KB - 1 Data Length
	MAX_PACKET_LENGTH = 64*1024 - 1 // Maximum 64 KB - 1 Packet Length

	CLS_NODE       = 1
	CLS_CLUSTER    = 2
	CLS_UNIVERSE   = 3
	CLS_SERVICE    = 4
	CLS_FEDERATION = 5

	TRIE_NODE_TYPE_KEY        = byte(0x01) // trie node type key
	TRIE_NODE_TYPE_ATTR_GROUP = byte(0x02) // trie node type attr group
)

Variables

This section is empty.

Functions

func AESPad

func AESPad(input []byte) []byte

func Base58Decode

func Base58Decode(b string) []byte

Decode Base58 format to byte array, return nil if failed

func Base58Encode

func Base58Encode(b []byte) string

Encode byte array to base58 format

func Close

func Close(f *os.File)

func DecodeUvarint64

func DecodeUvarint64(buf []byte) (uint64, int, error)

func DecodeVarchar

func DecodeVarchar(buf []byte) ([]byte, int, error)

func DecodeVarint64

func DecodeVarint64(buf []byte) (int64, int, error)

func ECDSACalculateY

func ECDSACalculateY(curve elliptic.Curve, x *big.Int) *big.Int

func ECDSAGenerateKey

func ECDSAGenerateKey() *ecdsa.PrivateKey

func ECDSAGetPrivateKey

func ECDSAGetPrivateKey(priv_bytes []byte) *ecdsa.PrivateKey

func ECDSAGetPublicKey

func ECDSAGetPublicKey(pub_bytes []byte) *ecdsa.PublicKey

func ECDSASign

func ECDSASign(priv_key *ecdsa.PrivateKey, hash []byte) (r, s *big.Int, err error)

func ECDSAVerify

func ECDSAVerify(pub_key *ecdsa.PublicKey, hash []byte, r, s *big.Int) bool

func EncodeUvarint64

func EncodeUvarint64(data uint64) []byte

func EncodeVarchar

func EncodeVarchar(data []byte) []byte

func EncodeVarint64

func EncodeVarint64(data int64) []byte

func LCExistPrivKey

func LCExistPrivKey(cls int, id string) bool

func LCExistPubKey

func LCExistPubKey(cls int, id string) bool

func LCGetEtcDir

func LCGetEtcDir(cls int) string

func LCLoadPrivKey

func LCLoadPrivKey(cls int, id string, secret []byte) (*ecdsa.PrivateKey, error)

ECDSA priv key for node

func LCLoadPrivKeyPrompt

func LCLoadPrivKeyPrompt(cls int, id string) (*ecdsa.PrivateKey, error)

ECDSA priv key for node

func LCLoadPubKey

func LCLoadPubKey(cls int, id string) (*ecdsa.PublicKey, error)

ECDSA pub key (X) for node

func LCSaveKeyPair

func LCSaveKeyPair(cls int, id string, pub_key, priv_key *big.Int, secret []byte) error

ECDSA pub / priv keys for node

func LCSaveKeyPairPrompt

func LCSaveKeyPairPrompt(cls int, id string, pub_key, priv_key *big.Int) error

ECDSA pub / priv keys for node

func LCSetLoggerFileTmp

func LCSetLoggerFileTmp() error

func LCSetLoggerStdout

func LCSetLoggerStdout() error

func Open

func Open(filename string) *os.File

func PromptPassphrase

func PromptPassphrase(repeat bool) ([]byte, error)

func PromptText

func PromptText(prompt string) string

func RandInt16

func RandInt16() int16

func RandInt16Range

func RandInt16Range(min, max int16) int16

func RandInt32

func RandInt32() int32

func RandInt32Range

func RandInt32Range(min, max int32) int32

func RandInt64

func RandInt64() int64

func RandInt64Range

func RandInt64Range(min, max int64) int64

func RandInt8

func RandInt8() int8

func RandInt8Range

func RandInt8Range(min, max int8) int8

func RandUint16

func RandUint16() uint16

func RandUint16Range

func RandUint16Range(min, max uint16) uint16

func RandUint32

func RandUint32() uint32

func RandUint32Range

func RandUint32Range(min, max uint32) uint32

func RandUint64

func RandUint64() uint64

func RandUint64Range

func RandUint64Range(min, max uint64) uint64

func RandUint8

func RandUint8() uint8

func RandUint8Range

func RandUint8Range(min, max uint8) uint8

func SumMD5

func SumMD5(data []byte) []byte

16 byte array

func SumSHA256

func SumSHA256(data []byte) []byte

32 byte array

func SumSHA256d

func SumSHA256d(data []byte) []byte

func Sync

func Sync(f *os.File)

func Ternary

func Ternary(statement bool, a, b interface{}) interface{}

func Write

func Write(f *os.File, size int)

Types

type EmptyKey

type EmptyKey struct {
}

func NewEmptyKey

func NewEmptyKey() *EmptyKey

func (*EmptyKey) Buf

func (k *EmptyKey) Buf() []byte

func (*EmptyKey) Compare

func (k *EmptyKey) Compare(c collection.IComparable) int

func (*EmptyKey) Copy

func (k *EmptyKey) Copy() IEncodable

func (*EmptyKey) CopyConstruct

func (k *EmptyKey) CopyConstruct() (IEncodable, error)

func (*EmptyKey) Decode

func (k *EmptyKey) Decode(IContext) (int, error)

func (*EmptyKey) Encode

func (k *EmptyKey) Encode(IContext) error

func (*EmptyKey) Equal

func (k *EmptyKey) Equal(o collection.IObject) bool

func (*EmptyKey) EstBufSize

func (k *EmptyKey) EstBufSize() int

func (*EmptyKey) HashUint32

func (k *EmptyKey) HashUint32(f func([]byte) uint32) uint32

func (*EmptyKey) IsDecoded

func (k *EmptyKey) IsDecoded() bool

func (*EmptyKey) IsEmpty

func (k *EmptyKey) IsEmpty() bool

func (*EmptyKey) IsEncoded

func (k *EmptyKey) IsEncoded() bool

func (*EmptyKey) Key

func (k *EmptyKey) Key() [][]byte

returns empty array

func (*EmptyKey) Print

func (k *EmptyKey) Print(w io.Writer, indent int)

func (*EmptyKey) SubKeyAt

func (k *EmptyKey) SubKeyAt(idx int) []byte

func (*EmptyKey) ToString

func (k *EmptyKey) ToString() string

type ICompressEncoder

type ICompressEncoder interface {
	Compress(data []byte) ([]byte, error)
	Decompress(data []byte) ([]byte, error)
}

type IConsensusID

type IConsensusID interface {
	ConsensusMagic() byte
	Buf() []byte
	Copy() IConsensusID
}

type IConsensusTime

type IConsensusTime interface {
	Buf() []byte
	GT(ict IConsensusTime) (bool, error)
	GE(ict IConsensusTime) (bool, error)
	EQ(ict IConsensusTime) (bool, error)
	NE(ict IConsensusTime) (bool, error)
	LT(ict IConsensusTime) (bool, error)
	LE(ict IConsensusTime) (bool, error)
}

func NewConsensusTime

func NewConsensusTime(buf []byte) (IConsensusTime, error)

type IContext

type IContext interface {
}

type IEncodable

type IEncodable interface {

	// whether Data is encoded      - always return true for Mapped Data
	//                                  - return true for Constructed Data if encoded buf cache exists
	//                                  - return false for Constructed Data if no encoded buf cache
	IsEncoded() bool

	// encode Data                  - for Constructed Data only, return error for Mapped Data
	//                                  - if successful, encoded buf is kept as part of Data object
	//                                  - bool param indicate whether to encode with parent Record context
	//                                  - byte return value is parent bits, return 0xff if this is self-encoded as Data
	Encode(ctx IContext) error

	// whether Data is decoded      - always return true for Constructed Data
	//                                  - return true for Mapped Data if data is decoded
	//                                  - return false for Mapped Data if data is not decoded
	IsDecoded() bool

	// decode Data                  - for Mapped Data only, return error for Constructed Data
	//                                  - if successful, individual data array, record list, or primitive data are decoded and kept as part of Data object
	//                                  - parent param is data encode from parent: 0x00 is no length; 0x01 is 1 byte length; 0x02 is 2 byte length; 0x03 is custom encoding
	//                                  - use 0xff if no parent
	Decode(ctx IContext) (int, error)

	// copy
	// - for mapped object, copy the underlying mapped byte array (read only)
	// - for constructed object, make a copy of the constructed object (modifiable)
	Copy() IEncodable
	// make a constructed (modifiable) copy of the object
	CopyConstruct() (IEncodable, error)

	// return encoded buf (byte array)
	Buf() []byte
	// estimated buf size
	EstBufSize() int
}

type IKey

type IKey interface {

	////////////////////////////////////////
	// embeded interfaces
	collection.IComparable
	collection.IHashable
	collection.IPrintable
	IEncodable

	////////////////////////////////////////
	// accessor to elements
	IsEmpty() bool // whether Key is nil
	Key() [][]byte
	SubKeyAt(idx int) []byte
}

type ILookupEncoder

type ILookupEncoder interface {
	EncodeLookup(data []byte) ([]byte, error)
	DecodeLookup(data []byte) ([]byte, error)
}

type IRecord

type IRecord interface {

	////////////////////////////////////////
	// embeded interfaces
	//collection.IPrintable
	IEncodable

	////////////////////////////////////////
	// accessor to elements
	Key() IKey                       // key content
	Value() IValue                   // value content
	Scheme() IValue                  // scheme content
	Timestamp() *time.Time           // 8 bytes unix nano timestamp
	Signature() (*big.Int, *big.Int) // optional 2 * 32 bytes signature

	////////////////////////////////////////
	// encoding, decoding, and buf
	RecordMagic() byte // 1 byte Record Magic          - return 0xff if not encoded
}

type IScheme

type IScheme interface {

	////////////////////////////////////////
	// embeded interfaces
	//collection.IPrintable
	IEncodable

	////////////////////////////////////////
	// accessor to elements
	Domain() []byte          // get Domain
	DomainName() string      // get Domain name
	Tablet() []byte          // get tablet
	TabletName() string      // get tablet name
	Buckets() [][]byte       // get buckets
	BucketAt(idx int) []byte // get bucket at idx

	////////////////////////////////////////
	// magic
	SchemeMagic() byte // scheme magic byte
}

type ITrie

type ITrie interface {

	////////////////////////////////////////
	// embedded interfaces
	IEncodable
	collection.IPrintable

	////////////////////////////////////////
	// accessor to elements
	Get(IKey) IValue         // get
	Put(IKey, IValue) IValue // put
	Remove(IKey) IValue      // remove
	Entries() int            // total size

	// Iterators
	Iterator() ITrieIterator                     // this is same as nil key that iterates all keys
	KeyIterator(key IKey) ITrieIterator          // nil key param returns iterator for all keys, otherwise return iterator for specified key and children
	RangeIterator(start, end IKey) ITrieIterator // return iterator for keys within given range, start inclusive, end not inclusive
}

type ITrieIterator

type ITrieIterator interface {
	Next() (IKey, IValue)
	HasNext() bool
	Peek() (IKey, IValue)
}

type ITrieNode

type ITrieNode interface {

	////////////////////////////////////////
	// embedded interfaces
	IEncodable
	collection.IPrintable

	////////////////////////////////////////
	// accessor to elements - parent, children, and keys
	FullKey() IKey                              // return full key
	NodeKey() []byte                            // trie node key is a sub key of IKey
	Parent() ITrieNode                          // link to parent
	Children() *collection.SortedMap            // a list of children
	ChildSize() int                             // child size
	GetChild(nodeKey []byte) ITrieNode          // get child by specified child key
	PutChild(nodeKey []byte, n ITrieNode) error // add child (automatically sort)
	RemoveChild(nodeKey []byte) error           // remote child

	////////////////////////////////////////
	// data
	Value() IValue         // get associated data
	SetValue(IValue) error // set associated data

	////////////////////////////////////////
	// offset
	Offset() uint32         // get offset when this TrieNode is encoded
	SetOffset(uint32) error // set offset when this TrieNode is encoded to
}

type IValue

type IValue interface {

	////////////////////////////////////////
	// embeded interfaces
	//collection.IPrintable
	IEncodable

	////////////////////////////////////////
	// accessor to elements
	IsNil() bool                        // whether Value is nil
	IsPrimitive() bool                  // whether this is Primitive Value
	IsValueArray() bool                 // whether this is Value Array
	IsRecordList() bool                 // whether this is Record List
	Size() uint16                       // size of the Value Array or Record List
	ValueAt(i uint16) (IValue, error)   // get i-th Value Element - for Value Array only
	RecordAt(i uint16) (IRecord, error) // get i-th Record Element - for Record List only
	LookupEncoder() ILookupEncoder      // get Lookup Encoder
	CompressEncoder() ICompressEncoder  // get Compress Encoder
	Value() []byte                      // get Value Content - for Primitive Value only

	////////////////////////////////////////
	// encoding, decoding, and buf
	ValueMagic() byte // 1 byte Value Magic            - return 0xff if not encoded
}

type Key

type Key struct {
	// contains filtered or unexported fields
}

func NewKey

func NewKey() *Key

func NewSimpleKey

func NewSimpleKey(simpleKey []byte) *Key

func NewStringKey

func NewStringKey(stringKey string) *Key

func (*Key) Add

func (k *Key) Add(subKey []byte) *Key

func (*Key) Buf

func (k *Key) Buf() []byte

func (*Key) Compare

func (k *Key) Compare(c collection.IComparable) int

func (*Key) Copy

func (k *Key) Copy() IEncodable

func (*Key) CopyConstruct

func (k *Key) CopyConstruct() (IEncodable, error)

func (*Key) Decode

func (k *Key) Decode(IContext) (int, error)

func (*Key) Encode

func (k *Key) Encode(IContext) error

func (*Key) Equal

func (k *Key) Equal(o collection.IObject) bool

func (*Key) EstBufSize

func (k *Key) EstBufSize() int

func (*Key) HashUint32

func (k *Key) HashUint32(f func([]byte) uint32) uint32

func (*Key) IsDecoded

func (k *Key) IsDecoded() bool

func (*Key) IsEmpty

func (k *Key) IsEmpty() bool

func (*Key) IsEncoded

func (k *Key) IsEncoded() bool

func (*Key) Key

func (k *Key) Key() [][]byte

returns empty array

func (*Key) Print

func (k *Key) Print(w io.Writer, indent int)

func (*Key) SubKeyAt

func (k *Key) SubKeyAt(idx int) []byte

func (*Key) ToString

func (k *Key) ToString() string

type LedgerTime

type LedgerTime struct {
	// contains filtered or unexported fields
}

func NewLedgerTime

func NewLedgerTime(t uint32) *LedgerTime

func (*LedgerTime) Buf

func (t *LedgerTime) Buf() []byte

func (*LedgerTime) EQ

func (t *LedgerTime) EQ(ict IConsensusTime) (bool, error)

func (*LedgerTime) GE

func (t *LedgerTime) GE(ict IConsensusTime) (bool, error)

func (*LedgerTime) GT

func (t *LedgerTime) GT(ict IConsensusTime) (bool, error)

func (*LedgerTime) LE

func (t *LedgerTime) LE(ict IConsensusTime) (bool, error)

func (*LedgerTime) LT

func (t *LedgerTime) LT(ict IConsensusTime) (bool, error)

func (*LedgerTime) NE

func (t *LedgerTime) NE(ict IConsensusTime) (bool, error)

type MPHTable

type MPHTable struct {
	// contains filtered or unexported fields
}

A Table is an immutable hash table that provides constant-time lookups of key indices using a minimal perfect hash.

func MPHBuild

func MPHBuild(keys []IKey, verify_by_key bool) *MPHTable

Build builds a Table from keys using the "Hash, displace, and compress" algorithm described in http://cmph.sourceforge.net/papers/esa09.pdf.

func NewMPHTable

func NewMPHTable(buf []byte) (*MPHTable, int, error)

parse MPHTable from []byte (deserialize)

func (*MPHTable) Encode

func (t *MPHTable) Encode() ([]byte, error)

serialize to []byte

func (*MPHTable) Lookup

func (t *MPHTable) Lookup(s IKey) (n uint32, ok bool)

Lookup searches for s in t and returns its index and whether it was found.

type MappedConsensusID

type MappedConsensusID struct {
	// contains filtered or unexported fields
}

func NewMappedConsensusID

func NewMappedConsensusID(buf []byte) (*MappedConsensusID, error)

func (*MappedConsensusID) Buf

func (c *MappedConsensusID) Buf() []byte

func (*MappedConsensusID) ConsensusMagic

func (c *MappedConsensusID) ConsensusMagic() byte

func (*MappedConsensusID) Copy

func (c *MappedConsensusID) Copy() IConsensusID

type MappedKey

type MappedKey struct {
	// contains filtered or unexported fields
}

func NewMappedKey

func NewMappedKey(buf []byte) (*MappedKey, int, error)

func (*MappedKey) Buf

func (k *MappedKey) Buf() []byte

func (*MappedKey) Compare

func (k *MappedKey) Compare(c collection.IComparable) int

func (*MappedKey) Copy

func (k *MappedKey) Copy() IEncodable

func (*MappedKey) CopyConstruct

func (k *MappedKey) CopyConstruct() (IEncodable, error)

func (*MappedKey) Decode

func (k *MappedKey) Decode(IContext) (int, error)

func (*MappedKey) Encode

func (k *MappedKey) Encode(IContext) error

func (*MappedKey) Equal

func (k *MappedKey) Equal(o collection.IObject) bool

func (*MappedKey) EstBufSize

func (k *MappedKey) EstBufSize() int

func (*MappedKey) HashUint32

func (k *MappedKey) HashUint32(f func([]byte) uint32) uint32

func (*MappedKey) IsDecoded

func (k *MappedKey) IsDecoded() bool

func (*MappedKey) IsEmpty

func (k *MappedKey) IsEmpty() bool

func (*MappedKey) IsEncoded

func (k *MappedKey) IsEncoded() bool

func (*MappedKey) Key

func (k *MappedKey) Key() [][]byte

func (*MappedKey) Print

func (k *MappedKey) Print(w io.Writer, indent int)

func (*MappedKey) SubKeyAt

func (k *MappedKey) SubKeyAt(idx int) []byte

func (*MappedKey) ToString

func (k *MappedKey) ToString() string

type MappedRecord

type MappedRecord struct {
	// contains filtered or unexported fields
}

func NewMappedRecord

func NewMappedRecord(buf []byte) (*MappedRecord, int, error)

func (*MappedRecord) Buf

func (r *MappedRecord) Buf() []byte

func (*MappedRecord) Copy

func (r *MappedRecord) Copy() IEncodable

func (*MappedRecord) CopyConstruct

func (r *MappedRecord) CopyConstruct() (IEncodable, error)

func (*MappedRecord) Decode

func (r *MappedRecord) Decode(IContext) (length int, err error)

func (*MappedRecord) Encode

func (r *MappedRecord) Encode(IContext) error

func (*MappedRecord) EstBufSize

func (r *MappedRecord) EstBufSize() int

func (*MappedRecord) IsDecoded

func (r *MappedRecord) IsDecoded() bool

func (*MappedRecord) IsEncoded

func (r *MappedRecord) IsEncoded() bool

func (*MappedRecord) Key

func (r *MappedRecord) Key() IKey

func (*MappedRecord) RecordMagic

func (r *MappedRecord) RecordMagic() byte

func (*MappedRecord) Scheme

func (r *MappedRecord) Scheme() IValue

func (*MappedRecord) Signature

func (r *MappedRecord) Signature() (*big.Int, *big.Int)

func (*MappedRecord) Timestamp

func (r *MappedRecord) Timestamp() *time.Time

func (*MappedRecord) Value

func (r *MappedRecord) Value() IValue

type MappedScheme

type MappedScheme struct {
	// contains filtered or unexported fields
}

func NewMappedSchemd

func NewMappedSchemd(buf []byte) *MappedScheme

func (*MappedScheme) BucketAt

func (s *MappedScheme) BucketAt(idx int) []byte

func (*MappedScheme) Buckets

func (s *MappedScheme) Buckets() [][]byte

func (*MappedScheme) Buf

func (s *MappedScheme) Buf() []byte

func (*MappedScheme) Copy

func (s *MappedScheme) Copy() IEncodable

func (*MappedScheme) CopyConstruct

func (s *MappedScheme) CopyConstruct() (IEncodable, error)

func (*MappedScheme) Decode

func (s *MappedScheme) Decode(IContext) (int, error)

func (*MappedScheme) Domain

func (s *MappedScheme) Domain() []byte

func (*MappedScheme) DomainName

func (s *MappedScheme) DomainName() string

func (*MappedScheme) Encode

func (s *MappedScheme) Encode(IContext) error

func (*MappedScheme) EstBufSize

func (s *MappedScheme) EstBufSize() int

func (*MappedScheme) IsDecoded

func (s *MappedScheme) IsDecoded() bool

func (*MappedScheme) IsEncoded

func (s *MappedScheme) IsEncoded() bool

func (*MappedScheme) SchemeMagic

func (s *MappedScheme) SchemeMagic() byte

func (*MappedScheme) Tablet

func (s *MappedScheme) Tablet() []byte

func (*MappedScheme) TabletName

func (s *MappedScheme) TabletName() string

type MappedTrie

type MappedTrie struct {
	// contains filtered or unexported fields
}

func NewMappedTrie

func NewMappedTrie(buf []byte) (*MappedTrie, int, error)

func (*MappedTrie) Buf

func (t *MappedTrie) Buf() []byte

func (*MappedTrie) Copy

func (t *MappedTrie) Copy() IEncodable

func (*MappedTrie) CopyConstruct

func (t *MappedTrie) CopyConstruct() (IEncodable, error)

func (*MappedTrie) Decode

func (t *MappedTrie) Decode(IContext) (int, error)

func (*MappedTrie) Encode

func (t *MappedTrie) Encode(IContext) error

func (*MappedTrie) EstBufSize

func (t *MappedTrie) EstBufSize() int

func (*MappedTrie) Get

func (t *MappedTrie) Get(k IKey) IValue

func (*MappedTrie) IsDecoded

func (t *MappedTrie) IsDecoded() bool

func (*MappedTrie) IsEncoded

func (t *MappedTrie) IsEncoded() bool

func (*MappedTrie) Iterator

func (t *MappedTrie) Iterator() ITrieIterator

func (*MappedTrie) KeyIterator

func (t *MappedTrie) KeyIterator(k IKey) ITrieIterator

func (*MappedTrie) Print

func (t *MappedTrie) Print(w io.Writer, indent int)

func (*MappedTrie) RangeIterator

func (t *MappedTrie) RangeIterator(start, end IKey) ITrieIterator

func (*MappedTrie) Set

func (t *MappedTrie) Set(IKey, IValue) IValue

func (*MappedTrie) ToString

func (t *MappedTrie) ToString() string

type MappedTrieNode

type MappedTrieNode struct {
	// contains filtered or unexported fields
}

func NewMappedTrieNode

func NewMappedTrieNode(parent ITrieNode, buf []byte, offset uint32, known_nodes map[uint32]ITrieNode) (*MappedTrieNode, int, error)

func (*MappedTrieNode) Buf

func (tn *MappedTrieNode) Buf() []byte

func (*MappedTrieNode) ChildSize

func (tn *MappedTrieNode) ChildSize() int

func (*MappedTrieNode) Children

func (tn *MappedTrieNode) Children() *collection.SortedMap

func (*MappedTrieNode) Copy

func (tn *MappedTrieNode) Copy() IEncodable

func (*MappedTrieNode) CopyConstruct

func (tn *MappedTrieNode) CopyConstruct() (IEncodable, error)

func (*MappedTrieNode) Decode

func (tn *MappedTrieNode) Decode(IContext) (int, error)

func (*MappedTrieNode) Encode

func (tn *MappedTrieNode) Encode(IContext) error

func (*MappedTrieNode) EstBufSize

func (tn *MappedTrieNode) EstBufSize() int

func (*MappedTrieNode) FullKey

func (tn *MappedTrieNode) FullKey() IKey

func (*MappedTrieNode) GetChild

func (tn *MappedTrieNode) GetChild(nodeKey []byte) ITrieNode

func (*MappedTrieNode) IsDecoded

func (tn *MappedTrieNode) IsDecoded() bool

func (*MappedTrieNode) IsEncoded

func (tn *MappedTrieNode) IsEncoded() bool

func (*MappedTrieNode) NodeKey

func (tn *MappedTrieNode) NodeKey() []byte

func (*MappedTrieNode) Offset

func (tn *MappedTrieNode) Offset() uint32

func (*MappedTrieNode) Parent

func (tn *MappedTrieNode) Parent() ITrieNode

func (*MappedTrieNode) Print

func (tn *MappedTrieNode) Print(w io.Writer, indent int)

func (*MappedTrieNode) PutChild

func (tn *MappedTrieNode) PutChild(nodeKey []byte, n ITrieNode) error

func (*MappedTrieNode) RemoveChild

func (tn *MappedTrieNode) RemoveChild(nodeKey []byte) error

func (*MappedTrieNode) SetOffset

func (tn *MappedTrieNode) SetOffset(uint32) error

func (*MappedTrieNode) SetValue

func (tn *MappedTrieNode) SetValue(IValue) error

func (*MappedTrieNode) ToString

func (tn *MappedTrieNode) ToString() string

func (*MappedTrieNode) Value

func (tn *MappedTrieNode) Value() IValue

type Primitive

type Primitive struct {
	// contains filtered or unexported fields
}

func NewPrimitive

func NewPrimitive(data []byte) *Primitive

func (*Primitive) Buf

func (d *Primitive) Buf() []byte

func (*Primitive) CompressEncoder

func (d *Primitive) CompressEncoder() ICompressEncoder

func (*Primitive) Copy

func (d *Primitive) Copy() IEncodable

func (*Primitive) CopyConstruct

func (d *Primitive) CopyConstruct() (IEncodable, error)

func (*Primitive) Decode

func (d *Primitive) Decode(IContext) (int, error)

func (*Primitive) Encode

func (d *Primitive) Encode(IContext) error

func (*Primitive) EstBufSize

func (d *Primitive) EstBufSize() int

func (*Primitive) IsDecoded

func (d *Primitive) IsDecoded() bool

func (*Primitive) IsEncoded

func (d *Primitive) IsEncoded() bool

func (*Primitive) IsNil

func (d *Primitive) IsNil() bool

func (*Primitive) IsPrimitive

func (d *Primitive) IsPrimitive() bool

func (*Primitive) IsRecordList

func (d *Primitive) IsRecordList() bool

func (*Primitive) IsValueArray

func (d *Primitive) IsValueArray() bool

func (*Primitive) LookupEncoder

func (d *Primitive) LookupEncoder() ILookupEncoder

func (*Primitive) RecordAt

func (d *Primitive) RecordAt(idx uint16) (IRecord, error)

func (*Primitive) Size

func (d *Primitive) Size() uint16

func (*Primitive) Value

func (d *Primitive) Value() []byte

func (*Primitive) ValueAt

func (d *Primitive) ValueAt(idx uint16) (IValue, error)

func (*Primitive) ValueMagic

func (d *Primitive) ValueMagic() byte

type RaftTime

type RaftTime struct {
	// contains filtered or unexported fields
}

func NewRaftTime

func NewRaftTime(term, millis, count uint32) *RaftTime

func (*RaftTime) Buf

func (t *RaftTime) Buf() []byte

func (*RaftTime) EQ

func (t *RaftTime) EQ(ict IConsensusTime) (bool, error)

func (*RaftTime) GE

func (t *RaftTime) GE(ict IConsensusTime) (bool, error)

func (*RaftTime) GT

func (t *RaftTime) GT(ict IConsensusTime) (bool, error)

func (*RaftTime) LE

func (t *RaftTime) LE(ict IConsensusTime) (bool, error)

func (*RaftTime) LT

func (t *RaftTime) LT(ict IConsensusTime) (bool, error)

func (*RaftTime) NE

func (t *RaftTime) NE(ict IConsensusTime) (bool, error)

type Record

type Record struct {
	// contains filtered or unexported fields
}

func NewRecord

func NewRecord() *Record

func (*Record) Buf

func (r *Record) Buf() []byte

func (*Record) Copy

func (r *Record) Copy() IEncodable

func (*Record) CopyConstruct

func (r *Record) CopyConstruct() (IEncodable, error)

func (*Record) Decode

func (r *Record) Decode(IContext) (int, error)

func (*Record) Encode

func (r *Record) Encode(IContext) error

func (*Record) EstBufSize

func (r *Record) EstBufSize() int

func (*Record) IsDecoded

func (r *Record) IsDecoded() bool

func (*Record) IsEncoded

func (r *Record) IsEncoded() bool

func (*Record) Key

func (r *Record) Key() IKey

func (*Record) RecordMagic

func (r *Record) RecordMagic() byte

func (*Record) Scheme

func (r *Record) Scheme() IValue

func (*Record) SetK

func (r *Record) SetK(key []byte) *Record

func (*Record) SetKey

func (r *Record) SetKey(key IKey) *Record

func (*Record) SetS

func (r *Record) SetS(scheme []byte) *Record

func (*Record) SetScheme

func (r *Record) SetScheme(scheme IValue) *Record

func (*Record) SetSignature

func (r *Record) SetSignature(R, S *big.Int) *Record

func (*Record) SetTimestamp

func (r *Record) SetTimestamp(t *time.Time) *Record

func (*Record) SetV

func (r *Record) SetV(value []byte) *Record

func (*Record) SetValue

func (r *Record) SetValue(value IValue) *Record

func (*Record) Signature

func (r *Record) Signature() (*big.Int, *big.Int)

func (*Record) Timestamp

func (r *Record) Timestamp() *time.Time

func (*Record) Value

func (r *Record) Value() IValue

type RecordList

type RecordList struct {
	// contains filtered or unexported fields
}

func NewRecordList

func NewRecordList() *RecordList

func (*RecordList) Append

func (d *RecordList) Append(record IRecord) *RecordList

func (*RecordList) Buf

func (d *RecordList) Buf() []byte

func (*RecordList) CompressEncoder

func (d *RecordList) CompressEncoder() ICompressEncoder

func (*RecordList) Copy

func (d *RecordList) Copy() IEncodable

func (*RecordList) CopyConstruct

func (d *RecordList) CopyConstruct() (IEncodable, error)

func (*RecordList) Decode

func (d *RecordList) Decode(IContext) (int, error)

func (*RecordList) DeleteAt

func (d *RecordList) DeleteAt(idx uint16) *RecordList

func (*RecordList) Encode

func (d *RecordList) Encode(IContext) error

func (*RecordList) EstBufSize

func (d *RecordList) EstBufSize() int

func (*RecordList) IsDecoded

func (d *RecordList) IsDecoded() bool

func (*RecordList) IsEncoded

func (d *RecordList) IsEncoded() bool

func (*RecordList) IsNil

func (d *RecordList) IsNil() bool

func (*RecordList) IsPrimitive

func (d *RecordList) IsPrimitive() bool

func (*RecordList) IsRecordList

func (d *RecordList) IsRecordList() bool

func (*RecordList) IsValueArray

func (d *RecordList) IsValueArray() bool

func (*RecordList) LookupEncoder

func (d *RecordList) LookupEncoder() ILookupEncoder

func (*RecordList) RecordAt

func (d *RecordList) RecordAt(idx uint16) (IRecord, error)

func (*RecordList) Size

func (d *RecordList) Size() uint16

func (*RecordList) Value

func (d *RecordList) Value() []byte

func (*RecordList) ValueAt

func (d *RecordList) ValueAt(idx uint16) (IValue, error)

func (*RecordList) ValueMagic

func (d *RecordList) ValueMagic() byte

type Scheme

type Scheme struct {
	// contains filtered or unexported fields
}

func NewScheme

func NewScheme() *Scheme

func (*Scheme) BucketAt

func (s *Scheme) BucketAt(idx int) []byte

func (*Scheme) Buckets

func (s *Scheme) Buckets() [][]byte

func (*Scheme) Buf

func (s *Scheme) Buf() []byte

func (*Scheme) Copy

func (s *Scheme) Copy() IEncodable

func (*Scheme) CopyConstruct

func (s *Scheme) CopyConstruct() (IEncodable, error)

func (*Scheme) Decode

func (s *Scheme) Decode(IContext) (int, error)

func (*Scheme) Domain

func (s *Scheme) Domain() []byte

func (*Scheme) DomainName

func (s *Scheme) DomainName() string

func (*Scheme) Encode

func (s *Scheme) Encode(IContext) error

func (*Scheme) EstBufSize

func (s *Scheme) EstBufSize() int

func (*Scheme) IsDecoded

func (s *Scheme) IsDecoded() bool

func (*Scheme) IsEncoded

func (s *Scheme) IsEncoded() bool

func (*Scheme) SchemeMagic

func (s *Scheme) SchemeMagic() byte

func (*Scheme) Tablet

func (s *Scheme) Tablet() []byte

func (*Scheme) TabletName

func (s *Scheme) TabletName() string

type SimpleMappedValue

type SimpleMappedValue struct {
	// contains filtered or unexported fields
}

func NewSimpleMappedValue

func NewSimpleMappedValue(buf []byte) (*SimpleMappedValue, int, error)

func (*SimpleMappedValue) Buf

func (d *SimpleMappedValue) Buf() []byte

func (*SimpleMappedValue) CompressEncoder

func (d *SimpleMappedValue) CompressEncoder() ICompressEncoder

func (*SimpleMappedValue) Copy

func (d *SimpleMappedValue) Copy() IEncodable

func (*SimpleMappedValue) CopyConstruct

func (d *SimpleMappedValue) CopyConstruct() (IEncodable, error)

func (*SimpleMappedValue) Decode

func (d *SimpleMappedValue) Decode(IContext) (int, error)

func (*SimpleMappedValue) Encode

func (d *SimpleMappedValue) Encode(IContext) error

func (*SimpleMappedValue) EstBufSize

func (d *SimpleMappedValue) EstBufSize() int

func (*SimpleMappedValue) IsDecoded

func (d *SimpleMappedValue) IsDecoded() bool

func (*SimpleMappedValue) IsEncoded

func (d *SimpleMappedValue) IsEncoded() bool

func (*SimpleMappedValue) IsNil

func (d *SimpleMappedValue) IsNil() bool

func (*SimpleMappedValue) IsPrimitive

func (d *SimpleMappedValue) IsPrimitive() bool

func (*SimpleMappedValue) IsRecordList

func (d *SimpleMappedValue) IsRecordList() bool

func (*SimpleMappedValue) IsValueArray

func (d *SimpleMappedValue) IsValueArray() bool

func (*SimpleMappedValue) LookupEncoder

func (d *SimpleMappedValue) LookupEncoder() ILookupEncoder

func (*SimpleMappedValue) RecordAt

func (d *SimpleMappedValue) RecordAt(i uint16) (IRecord, error)

func (*SimpleMappedValue) Size

func (d *SimpleMappedValue) Size() uint16

func (*SimpleMappedValue) Value

func (d *SimpleMappedValue) Value() []byte

func (*SimpleMappedValue) ValueAt

func (d *SimpleMappedValue) ValueAt(i uint16) (IValue, error)

func (*SimpleMappedValue) ValueMagic

func (d *SimpleMappedValue) ValueMagic() byte

type StandardMappedValue

type StandardMappedValue struct {
	// contains filtered or unexported fields
}

func NewStandardMappedValue

func NewStandardMappedValue(buf []byte) (*StandardMappedValue, int, error)

func (*StandardMappedValue) Buf

func (d *StandardMappedValue) Buf() []byte

func (*StandardMappedValue) CompressEncoder

func (d *StandardMappedValue) CompressEncoder() ICompressEncoder

func (*StandardMappedValue) Copy

func (d *StandardMappedValue) Copy() IEncodable

func (*StandardMappedValue) CopyConstruct

func (d *StandardMappedValue) CopyConstruct() (IEncodable, error)

func (*StandardMappedValue) Decode

func (d *StandardMappedValue) Decode(IContext) (int, error)

func (*StandardMappedValue) Encode

func (d *StandardMappedValue) Encode(IContext) error

func (*StandardMappedValue) EstBufSize

func (d *StandardMappedValue) EstBufSize() int

func (*StandardMappedValue) IsDecoded

func (d *StandardMappedValue) IsDecoded() bool

func (*StandardMappedValue) IsEncoded

func (d *StandardMappedValue) IsEncoded() bool

func (*StandardMappedValue) IsNil

func (d *StandardMappedValue) IsNil() bool

func (*StandardMappedValue) IsPrimitive

func (d *StandardMappedValue) IsPrimitive() bool

func (*StandardMappedValue) IsRecordList

func (d *StandardMappedValue) IsRecordList() bool

func (*StandardMappedValue) IsValueArray

func (d *StandardMappedValue) IsValueArray() bool

func (*StandardMappedValue) LookupEncoder

func (d *StandardMappedValue) LookupEncoder() ILookupEncoder

func (*StandardMappedValue) RecordAt

func (d *StandardMappedValue) RecordAt(idx uint16) (IRecord, error)

func (*StandardMappedValue) Size

func (d *StandardMappedValue) Size() uint16

func (*StandardMappedValue) Value

func (d *StandardMappedValue) Value() []byte

func (*StandardMappedValue) ValueAt

func (d *StandardMappedValue) ValueAt(idx uint16) (IValue, error)

func (*StandardMappedValue) ValueMagic

func (d *StandardMappedValue) ValueMagic() byte

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

func NewTrie

func NewTrie() *Trie

func (*Trie) Buf

func (t *Trie) Buf() []byte

func (*Trie) Copy

func (t *Trie) Copy() IEncodable

func (*Trie) CopyConstruct

func (t *Trie) CopyConstruct() (IEncodable, error)

func (*Trie) Decode

func (t *Trie) Decode(IContext) (int, error)

func (*Trie) Encode

func (t *Trie) Encode(ctx IContext) error

func (*Trie) EstBufSize

func (t *Trie) EstBufSize() int

func (*Trie) Get

func (t *Trie) Get(k IKey) IValue

func (*Trie) IsDecoded

func (t *Trie) IsDecoded() bool

func (*Trie) IsEncoded

func (t *Trie) IsEncoded() bool

func (*Trie) Iterator

func (t *Trie) Iterator() ITrieIterator

func (*Trie) KeyIterator

func (t *Trie) KeyIterator(k IKey) ITrieIterator

func (*Trie) Print

func (t *Trie) Print(w io.Writer, indent int)

func (*Trie) RangeIterator

func (t *Trie) RangeIterator(start, end IKey) ITrieIterator

func (*Trie) Set

func (t *Trie) Set(k IKey, d IValue) IValue

func (*Trie) ToString

func (t *Trie) ToString() string

type TrieKeyIterator

type TrieKeyIterator struct {
	// contains filtered or unexported fields
}

func NewTrieKeyIterator

func NewTrieKeyIterator(root, curr ITrieNode) *TrieKeyIterator

func (*TrieKeyIterator) HasNext

func (i *TrieKeyIterator) HasNext() bool

func (*TrieKeyIterator) Next

func (i *TrieKeyIterator) Next() (IKey, IValue)

func (*TrieKeyIterator) Peek

func (i *TrieKeyIterator) Peek() (IKey, IValue)

type TrieNode

type TrieNode struct {
	// contains filtered or unexported fields
}

func NewTrieNode

func NewTrieNode(parent ITrieNode, nodeKey []byte, data IValue) *TrieNode

func (*TrieNode) Buf

func (tn *TrieNode) Buf() []byte

func (*TrieNode) ChildSize

func (tn *TrieNode) ChildSize() int

func (*TrieNode) Children

func (tn *TrieNode) Children() *collection.SortedMap

func (*TrieNode) Copy

func (tn *TrieNode) Copy() IEncodable

func (*TrieNode) CopyConstruct

func (tn *TrieNode) CopyConstruct() (IEncodable, error)

func (*TrieNode) Decode

func (tn *TrieNode) Decode(IContext) (int, error)

func (*TrieNode) Encode

func (tn *TrieNode) Encode(IContext) error

func (*TrieNode) EstBufSize

func (tn *TrieNode) EstBufSize() int

func (*TrieNode) FullKey

func (tn *TrieNode) FullKey() IKey

////////////////////////////////////// accessor to elements - parent, children, and keys

func (*TrieNode) GetChild

func (tn *TrieNode) GetChild(nodeKey []byte) ITrieNode

func (*TrieNode) IsDecoded

func (tn *TrieNode) IsDecoded() bool

func (*TrieNode) IsEncoded

func (tn *TrieNode) IsEncoded() bool

func (*TrieNode) NodeKey

func (tn *TrieNode) NodeKey() []byte

func (*TrieNode) Offset

func (tn *TrieNode) Offset() uint32

func (*TrieNode) Parent

func (tn *TrieNode) Parent() ITrieNode

func (*TrieNode) Print

func (tn *TrieNode) Print(w io.Writer, indent int)

func (*TrieNode) PutChild

func (tn *TrieNode) PutChild(nodeKey []byte, n ITrieNode) error

func (*TrieNode) RemoveChild

func (tn *TrieNode) RemoveChild(nodeKey []byte) error

func (*TrieNode) SetOffset

func (tn *TrieNode) SetOffset(offset uint32) error

func (*TrieNode) SetValue

func (tn *TrieNode) SetValue(data IValue) error

func (*TrieNode) ToString

func (tn *TrieNode) ToString() string

func (*TrieNode) Value

func (tn *TrieNode) Value() IValue

type TrieRangeIterator

type TrieRangeIterator struct {
	// contains filtered or unexported fields
}

func NewTrieRangeIterator

func NewTrieRangeIterator(root ITrieNode, start, end IKey) *TrieRangeIterator

func (*TrieRangeIterator) HasNext

func (i *TrieRangeIterator) HasNext() bool

func (*TrieRangeIterator) Next

func (i *TrieRangeIterator) Next() (IKey, IValue)

func (*TrieRangeIterator) Peek

func (i *TrieRangeIterator) Peek() (IKey, IValue)

type ValueArray

type ValueArray struct {
	// contains filtered or unexported fields
}

func NewValueArray

func NewValueArray() *ValueArray

func (*ValueArray) Append

func (d *ValueArray) Append(data IValue) *ValueArray

func (*ValueArray) Buf

func (d *ValueArray) Buf() []byte

func (*ValueArray) CompressEncoder

func (d *ValueArray) CompressEncoder() ICompressEncoder

func (*ValueArray) Copy

func (d *ValueArray) Copy() IEncodable

func (*ValueArray) CopyConstruct

func (d *ValueArray) CopyConstruct() (IEncodable, error)

func (*ValueArray) Decode

func (d *ValueArray) Decode(IContext) (int, error)

func (*ValueArray) DeleteAt

func (d *ValueArray) DeleteAt(idx uint16) *ValueArray

func (*ValueArray) Encode

func (d *ValueArray) Encode(IContext) error

func (*ValueArray) EstBufSize

func (d *ValueArray) EstBufSize() int

func (*ValueArray) IsDecoded

func (d *ValueArray) IsDecoded() bool

func (*ValueArray) IsEncoded

func (d *ValueArray) IsEncoded() bool

func (*ValueArray) IsNil

func (d *ValueArray) IsNil() bool

func (*ValueArray) IsPrimitive

func (d *ValueArray) IsPrimitive() bool

func (*ValueArray) IsRecordList

func (d *ValueArray) IsRecordList() bool

func (*ValueArray) IsValueArray

func (d *ValueArray) IsValueArray() bool

func (*ValueArray) LookupEncoder

func (d *ValueArray) LookupEncoder() ILookupEncoder

func (*ValueArray) RecordAt

func (d *ValueArray) RecordAt(idx uint16) (IRecord, error)

func (*ValueArray) Size

func (d *ValueArray) Size() uint16

func (*ValueArray) Value

func (d *ValueArray) Value() []byte

func (*ValueArray) ValueAt

func (d *ValueArray) ValueAt(idx uint16) (IValue, error)

func (*ValueArray) ValueMagic

func (d *ValueArray) ValueMagic() byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL