Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): initial contact flow implementation (#40)
- Loading branch information
Showing
15 changed files
with
316 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package p2p | ||
|
||
import "time" | ||
|
||
func NewOutgoingEvent(sender, receiver string, kind Kind) *Event { | ||
return &Event{ | ||
SenderAPIVersion: Version, | ||
CreatedAt: time.Now(), | ||
Kind: kind, | ||
SenderID: sender, | ||
ReceiverID: receiver, | ||
Direction: Event_Outgoing, | ||
} | ||
} | ||
|
||
func (e *Event) Validate() error { | ||
// FIXME: generate validation | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package p2p | ||
|
||
import "github.com/gogo/protobuf/proto" | ||
|
||
func (e *Event) SetAttrs(attrs proto.Message) error { | ||
raw, err := proto.Marshal(attrs) | ||
if err != nil { | ||
return err | ||
} | ||
e.Attributes = raw | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package entity | ||
|
||
func (c *Contact) Validate() error { | ||
if c == nil { | ||
return ErrInvalidEntity | ||
} | ||
return nil | ||
} | ||
|
||
func (c *Contact) Filtered() *Contact { | ||
return &Contact{ | ||
DisplayName: c.DisplayName, | ||
DisplayStatus: c.DisplayStatus, | ||
// FIXME: share sigchain | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package entity | ||
|
||
import "errors" | ||
|
||
var ( | ||
ErrInvalidEntity = errors.New("invalid entity") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package node | ||
|
||
import "errors" | ||
|
||
var ( | ||
ErrInvalidInput = errors.New("invalid input") | ||
ErrNotImplemented = errors.New("not implemented") | ||
ErrEntityAlreadyExists = errors.New("entity already exists") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.