Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notifications-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
notifications-bot
Commits
69e1a67a
Commit
69e1a67a
authored
Apr 14, 2021
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Move poll logic to comms
parent
51325fca
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
io/poll.go
+6
-34
6 additions, 34 deletions
io/poll.go
with
6 additions
and
34 deletions
io/poll.go
+
6
−
34
View file @
69e1a67a
...
...
@@ -17,9 +17,8 @@ package io
import
(
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
pb
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/comms/notificationsBot"
"gitlab.com/xx_network/comms/connect"
"google.golang.org/grpc"
)
...
...
@@ -34,46 +33,19 @@ type PollingConn interface {
// with a protocomms object.
type
NdfPoller
struct
{
permHost
*
connect
.
Host
pc
*
connect
.
Proto
Comms
pc
*
notificationsBot
.
Comms
}
// NewNdfPoller creates a new permconn object with a host and protocomms id.
func
NewNdfPoller
(
pc
*
connect
.
Proto
Comms
,
p
erm
Host
*
connect
.
Host
)
NdfPoller
{
func
NewNdfPoller
(
pc
*
notificationsBot
.
Comms
,
pHost
*
connect
.
Host
)
NdfPoller
{
return
NdfPoller
{
pc
:
pc
,
permHost
:
p
erm
Host
,
permHost
:
pHost
,
}
}
// PollNdf gets the NDF from the Permissioning server.
func
(
p
NdfPoller
)
PollNdf
()
(
*
pb
.
NDF
,
error
)
{
func
(
p
NdfPoller
)
PollNdf
(
ndfHash
[]
byte
)
(
*
pb
.
NDF
,
error
)
{
permHost
:=
p
.
permHost
// Create the Send Function
f
:=
func
(
conn
*
grpc
.
ClientConn
)
(
*
any
.
Any
,
error
)
{
// Set up the context
ctx
,
cancel
:=
connect
.
MessagingContext
()
defer
cancel
()
// We use an empty NDF Hash to request an NDF
ndfRequest
:=
&
pb
.
NDFHash
{
Hash
:
make
([]
byte
,
0
)}
// Send the message
clientConn
:=
pb
.
NewRegistrationClient
(
conn
)
resultMsg
,
err
:=
clientConn
.
PollNdf
(
ctx
,
ndfRequest
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
err
.
Error
())
}
return
ptypes
.
MarshalAny
(
resultMsg
)
}
// Execute the Send function
jww
.
TRACE
.
Printf
(
"Sending Request Ndf message..."
)
resultMsg
,
err
:=
p
.
pc
.
Send
(
permHost
,
f
)
if
err
!=
nil
{
return
nil
,
err
}
result
:=
&
pb
.
NDF
{}
err
=
ptypes
.
UnmarshalAny
(
resultMsg
,
result
)
return
result
,
err
return
pc
.
PollNdf
(
permHost
,
ndfHash
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment