Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
8827efe0
Commit
8827efe0
authored
2 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
first pass at channel send logging
parent
68c03dbe
No related branches found
No related tags found
3 merge requests
!510
Release
,
!427
Modify send code to use a debug tag that includes a msgDigest. This is set by...
,
!340
Project/channels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
channels/send.go
+30
-3
30 additions, 3 deletions
channels/send.go
with
30 additions
and
3 deletions
channels/send.go
+
30
−
3
View file @
8827efe0
...
...
@@ -9,6 +9,7 @@ package channels
import
(
"crypto/ed25519"
"fmt"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix"
...
...
@@ -18,6 +19,7 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime"
"golang.org/x/crypto/blake2b"
"google.golang.org/protobuf/proto"
"time"
)
...
...
@@ -40,6 +42,11 @@ func (m *manager) SendGeneric(channelID *id.ID, messageType MessageType,
msg
[]
byte
,
validUntil
time
.
Duration
,
params
cmix
.
CMIXParams
)
(
cryptoChannel
.
MessageID
,
rounds
.
Round
,
ephemeral
.
Id
,
error
)
{
sendPrint
:=
fmt
.
Sprintf
(
"Sending to ch %s type %d at %s - "
+
"contentsHash %d"
,
channelID
,
messageType
,
netTime
.
Now
(),
hashMsg
(
msg
))
defer
jww
.
INFO
.
Println
(
sendPrint
)
//find the channel
ch
,
err
:=
m
.
getChannel
(
channelID
)
if
err
!=
nil
{
...
...
@@ -110,22 +117,36 @@ func (m *manager) SendGeneric(channelID *id.ID, messageType MessageType,
return
usrMsgSerial
,
nil
}
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Denoting pending send at %s"
,
netTime
.
Now
())
uuid
,
err
:=
m
.
st
.
denotePendingSend
(
channelID
,
&
userMessageInternal
{
userMessage
:
usrMsg
,
channelMessage
:
chMsg
,
messageID
:
msgId
,
})
if
err
!=
nil
{
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Denoting pending send failed: %s"
,
err
.
Error
())
return
cryptoChannel
.
MessageID
{},
rounds
.
Round
{},
ephemeral
.
Id
{},
err
}
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Broadcasting message at %s"
,
netTime
.
Now
())
r
,
ephid
,
err
:=
ch
.
broadcast
.
BroadcastWithAssembler
(
assemble
,
params
)
if
err
!=
nil
{
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Broadcasting failed at %s, denoting "
+
"failure: %s"
,
netTime
.
Now
(),
err
.
Error
())
errDenote
:=
m
.
st
.
failedSend
(
uuid
)
if
errDenote
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to update for a failed send to
"
+
"
%s
: %
+v
"
,
channelID
,
err
)
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Failed to denote failure of
"
+
"
broadcast
: %
s
"
,
err
.
Error
()
)
}
return
cryptoChannel
.
MessageID
{},
rounds
.
Round
{},
ephemeral
.
Id
{},
err
}
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Broadcast succeeded at %s, denoting "
+
"send success"
,
netTime
.
Now
())
err
=
m
.
st
.
send
(
uuid
,
msgId
,
r
)
if
err
!=
nil
{
sendPrint
+=
fmt
.
Sprintf
(
"
\n\t
Denotation of send success failed: "
+
"%s"
,
err
.
Error
())
}
return
msgId
,
r
,
ephid
,
err
}
...
...
@@ -288,3 +309,9 @@ func (m *manager) SendReaction(channelID *id.ID, reaction string,
return
m
.
SendGeneric
(
channelID
,
Reaction
,
reactMarshaled
,
ValidForever
,
params
)
}
func
hashMsg
(
msg
[]
byte
)
[]
byte
{
h
,
_
:=
blake2b
.
New256
(
nil
)
h
.
Write
(
msg
)
return
h
.
Sum
(
nil
)
}
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