diff --git a/bindings/contact.go b/bindings/contact.go new file mode 100644 index 0000000000000000000000000000000000000000..0c96fc41685a56257544a3cd107986fb3357295e --- /dev/null +++ b/bindings/contact.go @@ -0,0 +1,75 @@ +package bindings + +import ( + "encoding/json" + "errors" + "gitlab.com/elixxir/client/interfaces/contact" +) + +/* fact object*/ +type Fact struct { + f *contact.Fact +} + +func (f *Fact) Get() string { + return f.f.Fact +} + +func (f *Fact) Type() int { + return int(f.f.T) +} + +/* contact object*/ +type Contact struct { + c *contact.Contact +} + +// GetID returns the user ID for this user. +func (c *Contact) GetID() []byte { + return c.c.ID.Bytes() +} + +// GetDHPublicKey returns the public key associated with the Contact. +func (c *Contact) GetDHPublicKey() []byte { + return c.c.DhPubKey.Bytes() +} + +// GetDHPublicKey returns hash of a DH proof of key ownership. +func (c *Contact) GetOwnershipProof() []byte { + return c.c.OwnershipProof +} + +// Returns a fact list for adding and getting facts to and from the contact +func (c *Contact) GetFactList() *FactList { + return &FactList{c: c.c} +} + +type FactList struct { + c *contact.Contact +} + +func (fl *FactList) Num() int { + return len(fl.c.Facts) +} + +func (fl *FactList) Get(i int) Fact { + return Fact{f: &(fl.c.Facts)[i]} +} + +func (fl *FactList) Add(fact string, factType int) error { + ft := contact.FactType(factType) + if !ft.IsValid() { + return errors.New("Invalid fact type") + } + fl.c.Facts = append(fl.c.Facts, contact.Fact{ + Fact: fact, + T: ft, + }) + return nil +} + +func (fl *FactList) Marshal() ([]byte, error) { + return json.Marshal(&fl.c.Facts) +} + +func unmarshalFactList diff --git a/interfaces/params/CMIX.go b/interfaces/params/CMIX.go index a77c10fa9748c1c3ffa2119f02ee9ddcfd926c95..0413b418ddd545319dc4ceb6f10d740a6c15b8ac 100644 --- a/interfaces/params/CMIX.go +++ b/interfaces/params/CMIX.go @@ -12,7 +12,7 @@ type CMIX struct { func GetDefaultCMIX() CMIX { return CMIX{ RoundTries: 3, - Timeout: 10 * time.Second, + Timeout: 25 * time.Second, RetryDelay: 2 * time.Second, } }