Reorganize Peer Init

This commit is contained in:
Sarah Jamie Lewis 2023-02-27 12:07:19 -08:00
parent 05e77604d2
commit 9abece0f50
1 changed files with 6 additions and 2 deletions

View File

@ -312,16 +312,20 @@ func (app *application) installProfile(profile peer.CwtchPeer) bool {
if app.peers[profile.GetOnion()] == nil {
eventBus := event.NewEventManager()
app.eventBuses[profile.GetOnion()] = eventBus
app.registerHooks(profile)
profile.Init(app.eventBuses[profile.GetOnion()])
// Initialize the Peer with the Given Event Bus
app.peers[profile.GetOnion()] = profile
profile.Init(app.eventBuses[profile.GetOnion()])
// Update the Peer with the Most Recent Experiment State...
settings := app.settings.ReadGlobalSettings()
profile.UpdateExperiments(settings.ExperimentsEnabled, settings.Experiments)
app.registerHooks(profile)
// Register the Peer With Application Plugins..
app.AddPeerPlugin(profile.GetOnion(), plugins.CONNECTIONRETRY) // Now Mandatory
// Finalize the Creation of Peer / Notify any Interfaces..
app.appBus.Publish(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: profile.GetOnion(), event.Created: event.False}))
return true
}