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

Merge branch 'XX-2876/Re-reg' into 'release'

Resolve XX-2876 "/re reg"

Closes XX-2876

See merge request !477
parents 8008d3a4 b964e54b
No related branches found
No related tags found
No related merge requests found
......@@ -356,6 +356,7 @@ func (c *Client) GetSwitchboard() interfaces.Switchboard {
// events.
func (c *Client) GetRoundEvents() interfaces.RoundEvents {
jww.INFO.Printf("GetRoundEvents()")
jww.WARN.Printf("GetRoundEvents does not handle Client Errors edge case!")
return c.network.GetInstance().GetRoundEvents()
}
......
......@@ -297,15 +297,15 @@ func (c *Client) RegisterRoundEventsHandler(rid int, cb RoundEventCallback,
}
// RegisterMessageDeliveryCB allows the caller to get notified if the rounds a
// message was sent in sucesfully completed. Under the hood, this uses the same
// interface as RegisterRoundEventsHandler, but provides a convienet way to use
// message was sent in successfully completed. Under the hood, this uses the same
// interface as RegisterRoundEventsHandler, but provides a convent way to use
// the interface in its most common form, looking up the result of message
// retreval
// retrieval
//
// The callbacks will return at timeoutMS if no state update occurs
//
// This function takes the marshaled send report to ensure a memory leak does
// not occur as a result of both sides of the bindings holding a refrence to
// not occur as a result of both sides of the bindings holding a reference to
// the same pointer.
func (c *Client) RegisterMessageDeliveryCB(marshaledSendReport []byte,
mdc MessageDeliveryCallback, timeoutMS int) (*Unregister, error) {
......
......@@ -23,12 +23,13 @@ package network
// instance
import (
"gitlab.com/elixxir/client/network/gateway"
//"gitlab.com/elixxir/client/storage"
"bytes"
jww "github.com/spf13/jwalterweatherman"
bloom "gitlab.com/elixxir/bloomfilter"
"gitlab.com/elixxir/client/network/gateway"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/primitives/knownRounds"
"gitlab.com/elixxir/primitives/states"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id"
......@@ -62,7 +63,7 @@ func (m *manager) followNetwork(quitCh <-chan struct{}) {
}
}
var followCnt int = 0
var followCnt = 0
// executes each iteration of the follower
func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
......@@ -86,10 +87,10 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
LastUpdate: uint64(m.Instance.GetLastUpdateID()),
ClientID: m.Uid.Bytes(),
}
jww.TRACE.Printf("polling %s for NDF", gwHost)
jww.TRACE.Printf("Polling %s for NDF...", gwHost)
pollResp, err := comms.SendPoll(gwHost, &pollReq)
if err != nil {
jww.ERROR.Printf("%+v", err)
jww.ERROR.Printf("Unable to poll %s for NDF: %+v", gwHost, err)
return
}
......@@ -98,7 +99,7 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
gwRoundsState := &knownRounds.KnownRounds{}
err = gwRoundsState.Unmarshal(pollResp.KnownRounds)
if err != nil {
jww.ERROR.Printf("Failed to unmartial: %+v", err)
jww.ERROR.Printf("Failed to unmarshal: %+v", err)
return
}
var filterList []*bloom.Ring
......@@ -127,13 +128,13 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
if pollResp.PartialNDF != nil {
err = m.Instance.UpdatePartialNdf(pollResp.PartialNDF)
if err != nil {
jww.ERROR.Printf("%+v", err)
jww.ERROR.Printf("Unable to update partial NDF: %+v", err)
return
}
err = m.Instance.UpdateGatewayConnections()
if err != nil {
jww.ERROR.Printf("%+v", err)
jww.ERROR.Printf("Unable to update gateway connections: %+v", err)
return
}
}
......@@ -142,11 +143,48 @@ func (m *manager) follow(rng csprng.Source, comms followNetworkComms) {
// network
if pollResp.Updates != nil {
err = m.Instance.RoundUpdates(pollResp.Updates)
//jww.TRACE.Printf("%+v", pollResp.Updates)
if err != nil {
jww.ERROR.Printf("%+v", err)
return
}
// Iterate over ClientErrors for each RoundUpdate
for _, update := range pollResp.Updates {
// Ignore irrelevant updates
if update.State != uint32(states.COMPLETED) && update.State != uint32(states.FAILED) {
continue
}
for _, clientErr := range update.ClientErrors {
// If this Client appears in the ClientError
if bytes.Equal(clientErr.ClientId, m.Session.GetUser().ID.Marshal()) {
// Obtain relevant NodeGateway information
nGw, err := m.Instance.GetNodeAndGateway(gwHost.GetId())
if err != nil {
jww.ERROR.Printf("Unable to get NodeGateway: %+v", err)
return
}
nid, err := nGw.Node.GetNodeId()
if err != nil {
jww.ERROR.Printf("Unable to get NodeID: %+v", err)
return
}
// FIXME: Should be able to trigger proper type of round event
// FIXME: without mutating the RoundInfo. Signature also needs verified
// FIXME: before keys are deleted
update.State = uint32(states.FAILED)
m.Instance.GetRoundEvents().TriggerRoundEvent(update)
// Delete all existing keys and trigger a re-registration with the relevant Node
m.Session.Cmix().Remove(nid)
m.Instance.GetAddGatewayChan() <- nGw
}
}
}
}
// ---- Round Processing -----
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment