Documentation ¶
Index ¶
- Constants
- Variables
- func Addr(theBytes ...[]byte) []byte
- func GetBoolFromInterface(v interface{}, name string) bool
- func Hash(theBytes ...[]byte) []byte
- func HashToAddr(theBytes []byte) []byte
- type BitVector
- type Bool
- type BoolDoubleArray
- type Chan
- type ImgType
- type Lock
- type LockMap
- func (l *LockMap) Lock(id *PttID) error
- func (l *LockMap) MustLock(id *PttID) (err error)
- func (l *LockMap) RLock(id *PttID) error
- func (l *LockMap) RUnlock(id *PttID) error
- func (l *LockMap) TryLock(id *PttID) error
- func (l *LockMap) TryRLock(id *PttID) error
- func (l *LockMap) Unlock(id *PttID) error
- type PttID
- func NewPttID() (*PttID, error)
- func NewPttIDFromAddrPostfix(addr *common.Address, postfix []byte) (*PttID, error)
- func NewPttIDFromKey(key *ecdsa.PrivateKey) (*PttID, error)
- func NewPttIDFromKeyPostfix(key *ecdsa.PrivateKey, postfix []byte) (*PttID, error)
- func NewPttIDFromPubkeyPostfix(key *ecdsa.PublicKey, postfix []byte) (*PttID, error)
- func NewPttIDWithPostifx(postfix []byte) (*PttID, error)
- func NewPttIDWithPubkeyAndRefID(key *ecdsa.PublicKey, refID *PttID) (*PttID, error)
- func NewPttIDWithRefID(key *ecdsa.PrivateKey, refID *PttID) (*PttID, error)
- func UnmarshalTextPttID(b []byte, isAllowNil bool) (*PttID, error)
- func (p *PttID) Clone() *PttID
- func (p *PttID) IsSameKey(key *ecdsa.PrivateKey) bool
- func (p *PttID) IsSameKeyWithNodeID(n *discover.NodeID) bool
- func (p *PttID) IsSameKeyWithPttID(p2 *PttID) bool
- func (p *PttID) IsSamePubKey(key *ecdsa.PublicKey) bool
- func (p *PttID) Marshal() ([]byte, error)
- func (p *PttID) MarshalJSON() ([]byte, error)
- func (p *PttID) MarshalText() ([]byte, error)
- func (p *PttID) String() string
- func (p *PttID) Unmarshal(theIDStr []byte) error
- func (p *PttID) UnmarshalJSON(b []byte) error
- func (p *PttID) UnmarshalText(b []byte) error
- type RaftState
- type Salt
- type Sig
- type Status
- type StatusClass
- type Timestamp
- func (t *Timestamp) IsEqMilli(t2 Timestamp) bool
- func (t *Timestamp) IsEqual(t2 Timestamp) bool
- func (t *Timestamp) IsLess(t2 Timestamp) bool
- func (t *Timestamp) IsLessEqual(t2 Timestamp) bool
- func (t *Timestamp) Marshal() ([]byte, error)
- func (t *Timestamp) NextHourTS() Timestamp
- func (t *Timestamp) ToDayTimestamp() (Timestamp, Timestamp)
- func (t *Timestamp) ToHRTimestamp() (Timestamp, Timestamp)
- func (t *Timestamp) ToMilli() Timestamp
- func (t *Timestamp) ToMonthTimestamp() (Timestamp, Timestamp)
- func (t *Timestamp) ToYearTimestamp() (Timestamp, Timestamp)
- type Version
Constants ¶
const ( Account1 uint Me1 Friend1 )
protocol-versions
const ( SizeTimestamp = 12 // uint64 + uint32 (Sizeof may align with 64bit) SizePostfix = common.AddressLength SizePttID = common.AddressLength + SizePostfix // address-length (integrate with user-id) SizeSalt = 32 OffsetHash = 12 )
const ( HRSeconds = 3600 DaySeconds = 86400 )
const ( MaxImageWidth = 10000 MaxImageHeight = 10000 )
Variables ¶
var ( ErrInvalidID = errors.New("invalid id") ErrInvalidTimestamp = errors.New("invalid timestamp") ErrInvalidBitVector = errors.New("invalid bit vector") ErrLock = errors.New("unable to lock") ErrUnlock = errors.New("unable to unlock") ErrClose = errors.New("unable to close") ErrLockClosed = errors.New("lock closed") ErrBusy = errors.New("busy") ErrInvalidLock = errors.New("invalid lock") ErrInvalidURL = errors.New("invalid url") ErrAlreadyExists = errors.New("already exists") ErrAlreadyDeleted = errors.New("already deleted") ErrAlreadyPending = errors.New("already pending") ErrAlreadyPendingDelete = errors.New("already pending delete") ErrInvalidNode = errors.New("invalid node") ErrNotImplemented = errors.New("not implemented") ErrNotBool = errors.New("not bool") ErrNotBoolDAry = errors.New("not bool double array") ErrInvalidStatus = errors.New("invalid status") )
var ( EmptyID = PttID{} MaxID = PttID{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, } EmptyIDBytes = EmptyID[:] ZeroTimestamp = Timestamp{0, 0} // 12345678901234567 123456789 MaxTimestamp = Timestamp{99999999999999999, 999999999} NIterLock = 100 OffsetSecond int64 = 0 )
id / timestamp
var GetTimestamp = func() (Timestamp, error) { now := time.Now().UTC() return TimeToTimestamp(now), nil }
Functions ¶
func GetBoolFromInterface ¶
func HashToAddr ¶
Types ¶
type BitVector ¶
type BitVector []uint64
func NewBitVector ¶
NewBitVector returns a new BitVector of length L
func UnmarshalBitVector ¶
func (BitVector) Clear ¶
Clear clears the bit at position N for N >= L this will access memory out of bounds of the backing array and panic
func (BitVector) Get ¶
Get returns the bit at position N as a uint64 for N >= L this will access memory out of bounds of the backing array and panic
func (BitVector) PopCount ¶
PopCount returns the nubmer of set bits in the bit vector the algorithm for PopCount on a single 64-bit word is from 1957 due to Donald B. Gillies and Jeffrey C. P. Miller and referenced by Donald Knuth
func (BitVector) Set ¶
Set sets the bit at position N for N >= L this will access memory out of bounds of the backing array and panic
func (BitVector) SetWithIsNew ¶
Set sets the bit at position N for N >= L this will access memory out of bounds of the backing array and panic
type BoolDoubleArray ¶
type BoolDoubleArray [][]Bool
func (BoolDoubleArray) MarshalJSON ¶
func (bdary BoolDoubleArray) MarshalJSON() ([]byte, error)
func (*BoolDoubleArray) UnmarshalJSON ¶
func (bdary *BoolDoubleArray) UnmarshalJSON(theBytes []byte) error
type Chan ¶
type Chan struct {
// contains filtered or unexported fields
}
Chan implements non-panic chan. Chan checks isClose first before passing to the channel.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
type LockMap ¶
type LockMap struct {
// contains filtered or unexported fields
}
LockMap implements per-ptt-id lock
func NewLockMap ¶
type PttID ¶
PttID is the id-representation of all applications.
PttID is constructed from PKI-framework, with priv-key and pub-key. PttID is the address-representation of pub-key.
func NewPttIDFromAddrPostfix ¶
NewPttIDFromAddrPostfix generates new PttID with the 1st part as the key-address and the 2nd part as postfix.
func NewPttIDFromKey ¶
func NewPttIDFromKey(key *ecdsa.PrivateKey) (*PttID, error)
NewPttIDFromKey generates new PttID with the 1st part as the key-address and the 2nd part as random.
func NewPttIDFromKeyPostfix ¶
func NewPttIDFromKeyPostfix(key *ecdsa.PrivateKey, postfix []byte) (*PttID, error)
NewPttIDFromKey generates new PttID with the 1st part as the key-address and the 2nd part as postfix.
func NewPttIDFromPubkeyPostfix ¶
NewPttIDFromPubkeyPostfix generates new PttID with the 1st part as the key-address and the 2nd part as postfix.
func NewPttIDWithPostifx ¶
NewPttID generates new PttID.
func NewPttIDWithPubkeyAndRefID ¶
NewPttIDWithRefID generates new PttID with the 1st part as the key-address and the 2nd part as the addr-part of refID.
func NewPttIDWithRefID ¶
func NewPttIDWithRefID(key *ecdsa.PrivateKey, refID *PttID) (*PttID, error)
NewPttIDWithRefID generates new PttID with the 1st part as the key-address and the 2nd part as the addr-part of refID.
func (*PttID) IsSameKeyWithPttID ¶
func (*PttID) MarshalJSON ¶
func (*PttID) MarshalText ¶
func (*PttID) UnmarshalJSON ¶
func (*PttID) UnmarshalText ¶
type RaftState ¶
type RaftState int
RaftStatus
const ( RaftStateFollower RaftState RaftStateCandidate RaftStateLeader )
type Status ¶
type Status int
Status
const ( StatusInvalid Status = iota StatusInit StatusInternalSync StatusInternalPending StatusPending StatusSync StatusToBeSynced StatusAlive StatusFailed // Putting intenal-deleted after alive. // Because it's the competition between update-object and pending-delete, which does not affect the new-object, and no dead-lock for pending-delete (referring to new-object). StatusInternalDeleted StatusInternalRevoke StatusInternalTransfer StatusInternalMigrate StatusInternalTerminal StatusPendingDeleted StatusPendingRevoke StatusPendingTransfer StatusPendingMigrate StatusPendingTerminal StatusDeleted StatusRevoked StatusTransferred StatusMigrated StatusTerminal )
func StatusToDeleteStatus ¶
type StatusClass ¶
type StatusClass int
const ( StatusClassInvalid StatusClass = iota StatusClassInternalPendingAlive StatusClassPendingAlive StatusClassAlive StatusClassFailed StatusClassInternalDelete StatusClassPendingDelete StatusClassInternalTerminal StatusClassPendingTerminal StatusClassDeleted StatusClassTerminal )
func StatusToStatusClass ¶
func StatusToStatusClass(status Status) StatusClass
func (StatusClass) String ¶
func (s StatusClass) String() string