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 node implementation (#22)
- Loading branch information
Showing
11 changed files
with
304 additions
and
135 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
Large diffs are not rendered by default.
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
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,10 @@ | ||
package main | ||
|
||
const banner = ` | ||
██████╗ ███████╗██████╗ ████████╗██╗ ██╗ | ||
██╔══██╗██╔════╝██╔══██╗╚══██╔══╝╚██╗ ██╔╝ | ||
██████╔╝█████╗ ██████╔╝ ██║ ╚████╔╝ | ||
██╔══██╗██╔══╝ ██╔══██╗ ██║ ╚██╔╝ | ||
██████╔╝███████╗██║ ██║ ██║ ██║ | ||
╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ | ||
` |
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
Empty file.
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,14 @@ | ||
package node | ||
|
||
type Node struct{} | ||
|
||
func New(opts ...nodeOptions) *Node { | ||
n := &Node{} | ||
|
||
for _, opt := range opts { | ||
opt(n) | ||
} | ||
return n | ||
} | ||
|
||
type nodeOptions func(n *Node) |
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,51 @@ | ||
package node | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"google.golang.org/grpc" | ||
|
||
"github.com/berty/berty/core/api/entity" | ||
"github.com/berty/berty/core/api/node" | ||
) | ||
|
||
type nodeapi struct{} | ||
|
||
func WithNodeGrpcServer(gs *grpc.Server) nodeOptions { | ||
return func(n *Node) { | ||
node.RegisterServiceServer(gs, n) | ||
} | ||
} | ||
|
||
// events | ||
|
||
func (n *Node) EventList(*node.Void, node.Service_EventListServer) error { | ||
return fmt.Errorf("not implemented") | ||
} | ||
|
||
func (n *Node) EventStream(*node.Void, node.Service_EventStreamServer) error { | ||
return fmt.Errorf("not implemented") | ||
} | ||
|
||
// contacts | ||
|
||
func (n *Node) ContactAcceptRequest(context.Context, *entity.Contact) (*entity.Contact, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
} | ||
|
||
func (n *Node) ContactRequest(context.Context, *node.ContactRequestInput) (*entity.Contact, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
} | ||
|
||
func (n *Node) ContactUpdate(context.Context, *entity.Contact) (*entity.Contact, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
} | ||
|
||
func (n *Node) ContactRemove(context.Context, *entity.Contact) (*entity.Contact, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
} | ||
|
||
func (n *Node) ContactList(*node.Void, node.Service_ContactListServer) error { | ||
return fmt.Errorf("not implemented") | ||
} |
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,22 @@ | ||
package node | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"google.golang.org/grpc" | ||
|
||
"github.com/berty/berty/core/api/p2p" | ||
) | ||
|
||
type p2papi struct{} | ||
|
||
func WithP2PGrpcServer(gs *grpc.Server) nodeOptions { | ||
return func(n *Node) { | ||
p2p.RegisterServiceServer(gs, n) | ||
} | ||
} | ||
|
||
func (n *Node) Handle(context.Context, *p2p.Event) (*p2p.Void, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
} |