Skip to content
Snippets Groups Projects
Commit 7ed1741d authored by benjamin's avatar benjamin
Browse files

fixed the random message id creation

parent 7bd7001c
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!403make unsent message ids actually random,!340Project/channels
......@@ -205,26 +205,25 @@ func (st *sendTracker) denotePendingSend(channelID *id.ID,
// approximate the lag due to round submission
ts := netTime.Now().Add(oneSecond)
// submit the message to the UI
uuid, err := st.trigger(channelID, umi, ts, receptionID.EphemeralIdentity{},
rounds.Round{}, Unsent)
if err != nil {
return 0, err
}
// create a random message id so there will not be collisions in a database
// that requires a unique message ID
stream := st.rngSrc.GetStream()
randMid := cryptoChannel.MessageID{}
num, err := stream.Read(randMid[:])
if num != len(randMid[:]) || err != nil {
num, err := stream.Read(umi.messageID[:])
if num != len(umi.messageID[:]) || err != nil {
jww.FATAL.Panicf("failed to get a random message ID, read "+
"len: %d, err: %+v", num, err)
}
stream.Close()
// submit the message to the UI
uuid, err := st.trigger(channelID, umi, ts, receptionID.EphemeralIdentity{},
rounds.Round{}, Unsent)
if err != nil {
return 0, err
}
// track the message on disk
st.handleDenoteSend(uuid, channelID, randMid,
st.handleDenoteSend(uuid, channelID, umi.messageID,
rounds.Round{})
return uuid, nil
}
......@@ -237,15 +236,6 @@ func (st *sendTracker) denotePendingAdminSend(channelID *id.ID,
// approximate the lag due to round submission
ts := netTime.Now().Add(oneSecond)
// submit the message to the UI
uuid, err := st.adminTrigger(channelID, cm, ts, cryptoChannel.MessageID{},
receptionID.EphemeralIdentity{},
rounds.Round{}, Unsent)
if err != nil {
return 0, err
}
// create a random message id so there will not be collisions in a database
// that requires a unique message ID
stream := st.rngSrc.GetStream()
......@@ -257,6 +247,15 @@ func (st *sendTracker) denotePendingAdminSend(channelID *id.ID,
}
stream.Close()
// submit the message to the UI
uuid, err := st.adminTrigger(channelID, cm, ts, randMid,
receptionID.EphemeralIdentity{},
rounds.Round{}, Unsent)
if err != nil {
return 0, err
}
// track the message on disk
st.handleDenoteSend(uuid, channelID, randMid,
rounds.Round{})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment