Skip to content
Snippets Groups Projects
Commit 8b0de77e authored by Jono Wenger's avatar Jono Wenger
Browse files

Fix Contact code formatting and go mod

parent 1a7a6a7b
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ require (
github.com/spf13/viper v1.7.1
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20201229200853-c403d72e877c
gitlab.com/elixxir/crypto v0.0.7-0.20201222203132-9b4cc1ae3da6
gitlab.com/elixxir/crypto v0.0.7-0.20210104173655-8a83c8beb556
gitlab.com/elixxir/ekv v0.1.4-0.20201217220111-9c7e8be21577
gitlab.com/elixxir/primitives v0.0.3-0.20201229212305-2ab1e938b1cb
gitlab.com/xx_network/comms v0.0.4-0.20201222193955-56206d700360
......
......@@ -266,6 +266,8 @@ gitlab.com/elixxir/crypto v0.0.3 h1:znCt/x2bL4y8czTPaaFkwzdgSgW3BJc/1+dxyf1jqVw=
gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA=
gitlab.com/elixxir/crypto v0.0.7-0.20201222203132-9b4cc1ae3da6 h1:Vyf2wJ1/CoHLznATpI+z84OJQ+sgAbpVLT9P1CNjSVI=
gitlab.com/elixxir/crypto v0.0.7-0.20201222203132-9b4cc1ae3da6/go.mod h1:NsIzH+TN592lMcmJGVzxUE64dObXuci7jo0qajyGahI=
gitlab.com/elixxir/crypto v0.0.7-0.20210104173655-8a83c8beb556 h1:TiFwplcpE2QmSyrSfOn97MfPxlKwBE2LSaoWeQAEgQo=
gitlab.com/elixxir/crypto v0.0.7-0.20210104173655-8a83c8beb556/go.mod h1:NsIzH+TN592lMcmJGVzxUE64dObXuci7jo0qajyGahI=
gitlab.com/elixxir/ekv v0.1.4-0.20201217220111-9c7e8be21577 h1:qT3ZO9GbKv7PcmakATsXsUdzn/hlm817ETOT/csDIak=
gitlab.com/elixxir/ekv v0.1.4-0.20201217220111-9c7e8be21577/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4=
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
......
......@@ -61,8 +61,8 @@ func (c Contact) Marshal() []byte {
if c.ID != nil {
buff.Write(c.ID.Marshal())
} else {
emptyID := make([]byte, id.ArrIDLen)
buff.Write(emptyID)
// Handle nil ID
buff.Write(make([]byte, id.ArrIDLen))
}
// Write DhPubKey
......@@ -83,7 +83,7 @@ func Unmarshal(b []byte) (Contact, error) {
var err error
buff := bytes.NewBuffer(b)
// Get size (in bytes) of each field
// Get size of each field
dhPubKeySize, _ := binary.Varint(buff.Next(sizeByteLength))
ownershipProofSize, _ := binary.Varint(buff.Next(sizeByteLength))
factsSize, _ := binary.Varint(buff.Next(sizeByteLength))
......@@ -104,23 +104,23 @@ func Unmarshal(b []byte) (Contact, error) {
// Handle nil key
c.DhPubKey = nil
} else {
err = c.DhPubKey.BinaryDecode(buff.Next(int(dhPubKeySize)))
if err != nil {
if err = c.DhPubKey.BinaryDecode(buff.Next(int(dhPubKeySize))); err != nil {
return Contact{}, errors.Errorf("Failed to binary decode Contact DhPubKey: %+v", err)
}
}
// Get OwnershipProof
c.OwnershipProof = buff.Next(int(ownershipProofSize))
if len(c.OwnershipProof) == 0 {
if ownershipProofSize == 0 {
// Handle nil OwnershipProof
c.OwnershipProof = nil
} else {
c.OwnershipProof = buff.Next(int(ownershipProofSize))
}
// Get and unstringify fact list
c.Facts, _, err = fact.UnstringifyFactList(string(buff.Next(int(factsSize))))
if err != nil {
return Contact{}, errors.Errorf("Failed to unstringify Fact List: %+v", err)
return Contact{}, errors.Errorf("Failed to unstringify Contact fact list: %+v", err)
}
return c, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment