Documentation ¶
Index ¶
- Constants
- Variables
- func VerifyMsg(msg Message) (bool, error)
- type Auth
- type DOBMsgContent
- type Group
- type Message
- type MsgReference
- type MsgValue
- type ParentSig
- type TimeProof
- type Universe
- func (md *Universe) Add(msg *Message) error
- func (md *Universe) AddUniverse(msg *Message) error
- func (md *Universe) CheckUserValid(userID common.Hash) bool
- func (md *Universe) GetMaxSeq(userID common.Hash) uint64
- func (md *Universe) GetMsgByID(mid interface{}) *Message
- func (md *Universe) GetUserDAG() *Group
- type UniverseGroup
- type User
Constants ¶
const ( TypeText = iota TypeDOB )
const (
UserStatusNormal = iota
)
Variables ¶
var ( ErrMsgFromInvalidUser = errors.New("msg from invalid user") ErrMsgAlreadyExist = errors.New("msg already exist") ErrMsgNotFound = errors.New("msg not found") ErrTPAlreadyExist = errors.New("time proof already exist") )
var (
ErrUserAlreadyExist = errors.New("user already exist")
)
Functions ¶
Types ¶
type DOBMsgContent ¶
func CreateDOBMsgContent ¶
func CreateDOBMsgContent(name string, extra string, auth *Auth) (*DOBMsgContent, error)
func (*DOBMsgContent) SignByParent ¶
func (mv *DOBMsgContent) SignByParent(user *User, privKey crypto.PrivateKey) error
type Message ¶
type Message struct { SenderID common.Hash `json:"senderID"` Reference []*MsgReference `json:"reference"` Value *MsgValue `json:"value"` Signature *crypto.Signature `json:"signature"` }
func CreateMsg ¶
func CreateMsg(user *User, value *MsgValue, privKey *crypto.PrivateKey, refs ...*MsgReference) (*Message, error)
type MsgReference ¶
type TimeProof ¶
type TimeProof struct {
// contains filtered or unexported fields
}
TimeProof value of vertex contain in dag is sequence number
type Universe ¶
type Universe struct {
// contains filtered or unexported fields
}
Universe Vertex of utD is time proof, ID of Vertex is the ID of user which msg set as the time proof, Reference of Vertex is source which this time proof split from Vertex of ugD is group, ID of Vertex is the ID of time proof which this group valid, Reference of Vertex is same with time proof reference
func NewUniverse ¶
NewUniverse create Universe the msg will also be used to create time proof as msg.SenderID
func (*Universe) Add ¶
Add will check if the msg from valid user, add new msg into Universe, and update time proof if msg.SenderID is belong to time proof
func (*Universe) AddUniverse ¶
AddTimeProof will get all messages save in Universe with same msg.SenderID and build the time proof by those messages
func (*Universe) CheckUserValid ¶
CheckUserValid check if the user valid in this Universe the msg.SenderID must valid in at least one tpDAG
func (*Universe) GetMaxSeq ¶
GetMaxSeq will return the max time proof sequence for time proof by the userID
func (*Universe) GetMsgByID ¶
GetMsgByID will return the msg by msg.ID() nil will be return if msg not exist
func (*Universe) GetUserDAG ¶
GetUserDAG return userDAG by time proof userID
type UniverseGroup ¶
type UniverseGroup struct {
// contains filtered or unexported fields
}
UniverseGroup value of vertex contain in dag is user status
type User ¶
type User struct { Name string `json:"name"` DOBExtra string `json:"extra"` Auth *Auth `json:"auth"` DOBMsg *Message `json:"dobMsg"` }
func CreateNewUser ¶
CreateNewUser create new user by cosign message The msg must be signed by user in local user dag. Both parents must be in the local use dag. Both parents fit the nature rules. The BOD struct signed by both parents.
func CreateRootUsers ¶
CreateRootUser try to create two root users by public key One Male user and one female user,
func (User) ID ¶
ID return the vertex.id, related to parents and value of the vertex ID cloud use as address of user account
func (*User) MarshalJSON ¶
func (User) ParentsID ¶
ParentsID return the ID of user parents, res[0] should be the female parent (id end by even) res[1] should be the male parent (id end by odd)