Skip to content
Snippets Groups Projects
Commit f587d711 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'hotfix/msgIdReuse' into 'project/Channels'

make unsent message ids actually random

See merge request !403
parents 7bd7001c 62d19544
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,26 @@ 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 {
umi.messageID = cryptoChannel.MessageID{}
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 +237,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 +248,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