Documentation ¶
Index ¶
- Constants
- Variables
- func GetLastMsg(udb UDB) (*core.Message, error)
- func GetLastMsgByUser(udb UDB, userID common.Hash) (*core.Message, error)
- func GetMsgByOrder(udb UDB, start *big.Int, size int) (msgs []*core.Message)
- func GetMsgCount(udb UDB) (count *big.Int, err error)
- func GetOrderCntByMsg(udb UDB, mid common.Hash) (order *big.Int, count *big.Int, err error)
- func GetRootUsers(udb UDB) (*core.User, *core.User, error)
- func SaveMsg(udb UDB, msg *core.Message) error
- func SaveRootUsers(udb UDB, users []*core.User) (err error)
- type Row
- type UDB
Constants ¶
View Source
const ( // BucketUser is used to save all users BucketUser = "user" // BucketMsg is used to save the msg (msg.ID/ msg) BucketMsg = "msg" // BucketMID is used to save msg.ID by order (order/msg.ID) BucketMID = "mid" // BucketMOD is used to save msg received sequence (msg.ID/order) BucketMOD = "mod" // BucketLastMID is used to save last msg.ID by user.ID BucketLastMID = "lmid" // BucketConfig is used to save config info when universe be created BucketConfig = "config" // BucketPeer is used to save the peer information BucketPeer = "peer" // ConfigRoot0 root user which gender is 0 ConfigRoot0 = "root0" // ConfigRoot1 root user which gender is 1 ConfigRoot1 = "root1" // ConfigMsgCount is the current message count in the universe ConfigMsgCount = "msg_count" // ConfigCurrentStep is the current step of initialize the universe // step 0 - create bucket // step 1 - roots saved ConfigCurrentStep = "current_step" // ConfigLocalNodeKey is the local node key ConfigLocalNodeKey = "local_node_key" // ConfigUniverseDimension is universe dimension, depends on how your view the universe, // just related to calculate the distance between two common.Hash in this universe. ConfigUniverseDimension = "universe_dimension" // ConfigUniversePerimeter is local universe perimeter, same as dimension. ConfigUniversePerimeter = "universe_perimeter" // ConfigUniverseRedshiftConstant is local constant for dynamice universe model. ConfigUniverseRedshiftConstant = "universe_red_shift" )
View Source
const ( // StepInitDB is the step which all bucket in db have been created StepInitDB = iota // StepRootsSaved is the step which two roots have been saved into db StepRootsSaved )
Variables ¶
View Source
var ( // ErrMessageNotFound returns when the message not be found ErrMessageNotFound = errors.New("message can not be found") )
Functions ¶
func GetLastMsg ¶
GetLastMsg get the last message by order from db
func GetLastMsgByUser ¶
GetLastMsgByUser return the last message by userID
func GetMsgByOrder ¶
GetMsgByOrder get the message by order, for sync message between peers
func GetMsgCount ¶
GetMsgCount return the message count in local db
func GetOrderCntByMsg ¶
GetOrderCntByMsg get the message order by msgID
func GetRootUsers ¶
GetRootUsers get two root users from db
Types ¶
type UDB ¶
type UDB interface { Close() error CreateBucket(string) error DeleteBucket(string) error Set(string, string, []byte) error Get(string, string) ([]byte, error) Del(string, string) error Find(string, string, ...int) ([]*Row, error) }
UDB is a database interface for embed database, default db is bolt
Click to show internal directories.
Click to hide internal directories.