db

package
v0.0.0-...-dc1a94a Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemHistoryCount = 1000
)
View Source
const (
	MemHistoryP2PCount = 200
)

Variables

This section is empty.

Functions

func GenKey

func GenKey(pks [][]byte, gpks [][]byte) string

func GenKeyByPubKeys

func GenKeyByPubKeys(pks [][]byte, owner []byte) string

Types

type ChatFriends

type ChatFriends struct {
	Owner      string   `json:"-"`
	Friends    []Friend `json:"fs"`
	Groups     []string `json:"gs"`
	CreateTime int64    `json:"ct"`
	UpdateTime int64    `json:"ut"`
}

type ChatFriendsDb

type ChatFriendsDb struct {
	db.NbsDbInter
	// contains filtered or unexported fields
}

func GetChatFriendsDB

func GetChatFriendsDB() *ChatFriendsDb

func (*ChatFriendsDb) AddFriend

func (cf *ChatFriendsDb) AddFriend(ownerPk string, friendPK string) error

func (*ChatFriendsDb) AddGroup

func (cf *ChatFriendsDb) AddGroup(ownerPk string, group string) error

func (*ChatFriendsDb) AgreeFriend

func (cf *ChatFriendsDb) AgreeFriend(ownerPk string, friendPk string, agree bool) error

func (*ChatFriendsDb) DelFriend

func (cf *ChatFriendsDb) DelFriend(ownerPK string, friendPK string) error

func (*ChatFriendsDb) DelGroup

func (cf *ChatFriendsDb) DelGroup(ownerPK string, group string) error

func (*ChatFriendsDb) Find

func (cf *ChatFriendsDb) Find(ownerPk string) (*ChatFriends, error)

func (*ChatFriendsDb) FindFriend

func (cf *ChatFriendsDb) FindFriend(ownerPk string, friend string) (*Friend, error)

func (*ChatFriendsDb) FindGroup

func (cf *ChatFriendsDb) FindGroup(ownerPk string, grpId string) (string, error)

func (*ChatFriendsDb) Iterator

func (s *ChatFriendsDb) Iterator()

func (*ChatFriendsDb) Next

func (s *ChatFriendsDb) Next() (key string, meta *ChatFriends, r1 error)

func (*ChatFriendsDb) Save

func (s *ChatFriendsDb) Save()

type ChatGroupMemberDB

type ChatGroupMemberDB struct {
	db.NbsDbInter
	// contains filtered or unexported fields
}

func GetChatGrpMbrsDB

func GetChatGrpMbrsDB() *ChatGroupMemberDB

func (*ChatGroupMemberDB) AddMember

func (cgm *ChatGroupMemberDB) AddMember(grpId string, mbr string) error

func (*ChatGroupMemberDB) DelGroupMember

func (cgm *ChatGroupMemberDB) DelGroupMember(grpId string) error

func (*ChatGroupMemberDB) DelMember

func (cgm *ChatGroupMemberDB) DelMember(grpId string, mbr string) error

func (*ChatGroupMemberDB) Find

func (cgm *ChatGroupMemberDB) Find(grpId string) (*GroupMember, error)

func (*ChatGroupMemberDB) Insert

func (cgm *ChatGroupMemberDB) Insert(grpId string, owner string) error

func (*ChatGroupMemberDB) Iterator

func (cgm *ChatGroupMemberDB) Iterator()

func (*ChatGroupMemberDB) Next

func (cgm *ChatGroupMemberDB) Next() (key string, meta *GroupMember, r1 error)

type ChatGroupsDB

type ChatGroupsDB struct {
	db.NbsDbInter
	// contains filtered or unexported fields
}

func GetChatGroupsDB

func GetChatGroupsDB() *ChatGroupsDB

func (*ChatGroupsDB) DecRefer

func (cg *ChatGroupsDB) DecRefer(grpId string) error

func (*ChatGroupsDB) Find

func (cg *ChatGroupsDB) Find(grpId string) (*Group, error)

func (*ChatGroupsDB) IncRefer

func (cg *ChatGroupsDB) IncRefer(grpId string) error

func (*ChatGroupsDB) Insert

func (cg *ChatGroupsDB) Insert(grpID string, alias, owner string) error

func (*ChatGroupsDB) Iterator

func (s *ChatGroupsDB) Iterator()

func (*ChatGroupsDB) Next

func (s *ChatGroupsDB) Next() (key string, meta *Group, r1 error)

func (*ChatGroupsDB) UpdateAlias

func (cg *ChatGroupsDB) UpdateAlias(grpId string, alias string) error

type ChatUser

type ChatUser struct {
	Alias      string `json:"as"`
	PubKey     string `json:"-"`
	CreateTime int64  `json:"ct"`
	UpdateTime int64  `json:"ut"`
	ExpireTime int64  `json:"et"`
}

type ChatUsersDB

type ChatUsersDB struct {
	db.NbsDbInter
	// contains filtered or unexported fields
}

func GetChatUserDB

func GetChatUserDB() *ChatUsersDB

func (*ChatUsersDB) Find

func (s *ChatUsersDB) Find(pk string) (*ChatUser, error)

func (*ChatUsersDB) Insert

func (s *ChatUsersDB) Insert(alias string, pubkey string, tv int64) error

func (*ChatUsersDB) Iterator

func (s *ChatUsersDB) Iterator()

func (*ChatUsersDB) Next

func (s *ChatUsersDB) Next() (key string, meta *ChatUser, r1 error)

func (*ChatUsersDB) Remove

func (s *ChatUsersDB) Remove(pk string)

func (*ChatUsersDB) Save

func (s *ChatUsersDB) Save()

func (*ChatUsersDB) Update

func (s *ChatUsersDB) Update(alias string, pubkey string, tv int64) error

func (*ChatUsersDB) UpdateAlias

func (s *ChatUsersDB) UpdateAlias(pubkey string, alias string) error

func (*ChatUsersDB) UpdateExpireTime

func (s *ChatUsersDB) UpdateExpireTime(pubkey string, tv int64) error

type Friend

type Friend struct {
	OwnerPk string `json:"-"`
	PubKey  string `json:"pk"`
	AddTime int64  `json:"at"`
	Agree   bool   `json:"agr"`
}

type Group

type Group struct {
	Alias      string `json:"as"`
	GrpId      string `json:"-"`
	RefCnt     int    `json:"rcnt"`
	Owner      string `json:"owner"`
	CreateTime int64  `json:"ct"`
	UpdateTime int64  `json:"ut"`
}

type GroupKeys

type GroupKeys struct {
	PubKeys   []string `json:"pub_keys"`
	GroupKeys []string `json:"group_keys"`
}

func (*GroupKeys) GenKey

func (gk *GroupKeys) GenKey() string

type GroupKeysDb

type GroupKeysDb struct {
	db.NbsDbInter
	// contains filtered or unexported fields
}

func GetChatGrpKeysDb

func GetChatGrpKeysDb() *GroupKeysDb

func (*GroupKeysDb) Find

func (gkdb *GroupKeysDb) Find(key string) *GroupKeys

func (*GroupKeysDb) Insert

func (gkdb *GroupKeysDb) Insert(gks [][]byte, pks [][]byte) (key string)

func (*GroupKeysDb) Insert2

func (gkdb *GroupKeysDb) Insert2(gks []string, pks []string) (key string)

type GroupMember

type GroupMember struct {
	GrpID      string   `json:"-"`
	Owner      string   `json:"owr"`
	Members    []string `json:"mbrs"`
	CreateTime int64    `json:"ct"`
	UpdateTime int64    `json:"ut"`
}

type GroupMsg

type GroupMsg struct {
	AesKey string              `json:"aes_key"`
	Msg    string              `json:"msg"`
	Speek  address.ChatAddress `json:"seepk"`
}

type GroupMsgHDB

type GroupMsgHDB struct {
	hdb.HistoryDBIntf
	// contains filtered or unexported fields
}

func GetGMsgDb

func GetGMsgDb() *GroupMsgHDB

func (*GroupMsgHDB) FindMsg

func (gmdb *GroupMsgHDB) FindMsg(id string, begin, n int) (msgs []*LabelGroupMsg)

func (*GroupMsgHDB) FindMsg2

func (gmdb *GroupMsgHDB) FindMsg2(gid groupid.GrpID, pk string, begin, n int) (msgs []*LabelGroupMsg)

func (*GroupMsgHDB) Insert

func (gmdb *GroupMsgHDB) Insert(gid groupid.GrpID, keyHash string, speek address.ChatAddress, cipherTxt string)

type LabelGroupMsg

type LabelGroupMsg struct {
	AesKey string              `json:"aes_key"`
	Msg    string              `json:"msg"`
	Speek  address.ChatAddress `json:"speek"`
	Cnt    int                 `json:"cnt"`
	UCnt   int                 `json:"u_cnt"`
}

type LabelP2pMsg

type LabelP2pMsg struct {
	AesKey string `json:"aes_key"`
	Msg    string `json:"msg"`
	Cnt    int    `json:"cnt"`
}

type P2PMsg

type P2PMsg struct {
	AesKey string `json:"aes_key"`
	Msg    string `json:"msg"`
}

type P2PMsgHDB

type P2PMsgHDB struct {
	hdb.HistoryDBIntf
	// contains filtered or unexported fields
}

func GetP2PMsgDb

func GetP2PMsgDb() *P2PMsgHDB

func (*P2PMsgHDB) FindMsg

func (pdb *P2PMsgHDB) FindMsg(id string, begin, n int) (msgs []*LabelP2pMsg)

func (*P2PMsgHDB) Insert

func (pdb *P2PMsgHDB) Insert(id string, pk string, cipherTxt string)

type SecIdx

type SecIdx struct {
	Idx  int
	VIdx int
}

type Section

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

func Discrete2Section

func Discrete2Section(discretes []SecIdx) []Section

func (*Section) String

func (s *Section) String() string

Jump to

Keyboard shortcuts

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