Skip to content
Snippets Groups Projects
Commit bc7e458f authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

fixed some message pick up edge cases and a buffer bug

parent dcde5370
No related branches found
No related tags found
1 merge request!53Release
...@@ -156,8 +156,10 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round, ...@@ -156,8 +156,10 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round,
// If the gateway doesnt have the round, return an error // If the gateway doesnt have the round, return an error
msgResp, err := comms.RequestMessages(host, msgReq) msgResp, err := comms.RequestMessages(host, msgReq)
if err!=nil{ if err!=nil{
return nil, err //you need to default to a retryable errors because otherwise we cannot enumerate all errors
return nil, errors.WithMessage(err, gateway.RetryableError)
} }
if !msgResp.GetHasRound() { if !msgResp.GetHasRound() {
...@@ -165,7 +167,7 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round, ...@@ -165,7 +167,7 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round,
return message.Bundle{}, errors.WithMessage(errRtn, gateway.RetryableError) return message.Bundle{}, errors.WithMessage(errRtn, gateway.RetryableError)
} }
return msgResp, err return msgResp, nil
}, stop) }, stop)
jww.INFO.Printf("Received message for round %d, processing...", roundID) jww.INFO.Printf("Received message for round %d, processing...", roundID)
// Fail the round if an error occurs so it can be tried again later // Fail the round if an error occurs so it can be tried again later
......
...@@ -326,7 +326,7 @@ func (s *UncheckedRoundStore) marshal() ([]byte, error) { ...@@ -326,7 +326,7 @@ func (s *UncheckedRoundStore) marshal() ([]byte, error) {
// Write number of rounds the buffer // Write number of rounds the buffer
b := make([]byte, 8) b := make([]byte, 8)
binary.PutVarint(b, int64(len(s.list))) binary.BigEndian.PutUint32(b, uint32(len(s.list)))
buf.Write(b) buf.Write(b)
for rid, rnd := range s.list { for rid, rnd := range s.list {
...@@ -348,7 +348,7 @@ func (s *UncheckedRoundStore) unmarshal(data []byte) error { ...@@ -348,7 +348,7 @@ func (s *UncheckedRoundStore) unmarshal(data []byte) error {
buff := bytes.NewBuffer(data) buff := bytes.NewBuffer(data)
// Get number of rounds in list // Get number of rounds in list
length, _ := binary.Varint(buff.Next(8)) length := binary.BigEndian.Uint32(buff.Next(8))
for i := 0; i < int(length); i++ { for i := 0; i < int(length); i++ {
rnd := UncheckedRound{} rnd := UncheckedRound{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment