Commit 0f834536 authored by Jeremy Bokobza's avatar Jeremy Bokobza

renamed existing sessions to be more explicit

parent ea61224c
...@@ -59,28 +59,28 @@ namespace Breeze.TumbleBit.Client ...@@ -59,28 +59,28 @@ namespace Breeze.TumbleBit.Client
// get a list of cycles we expect to have at this height // get a list of cycles we expect to have at this height
var cycles = this.TumblerParameters.CycleGenerator.GetCycles(this.LastBlockReceivedHeight); var cycles = this.TumblerParameters.CycleGenerator.GetCycles(this.LastBlockReceivedHeight);
var states = cycles.SelectMany(c => this.Sessions.Where(s => s.StartCycle == c.Start)).ToList(); var existingSessions = cycles.SelectMany(c => this.Sessions.Where(s => s.StartCycle == c.Start)).ToList();
foreach (var state in states) foreach (var existingSession in existingSessions)
{ {
try try
{ {
// create a new session to be updated // create a new session to be updated
var session = new Session(); var session = new Session();
if (state.NegotiationClientState != null) if (existingSession.NegotiationClientState != null)
{ {
session.StartCycle = state.NegotiationClientState.CycleStart; session.StartCycle = existingSession.NegotiationClientState.CycleStart;
session.ClientChannelNegotiation = new ClientChannelNegotiation(this.TumblerParameters, state.NegotiationClientState); session.ClientChannelNegotiation = new ClientChannelNegotiation(this.TumblerParameters, existingSession.NegotiationClientState);
} }
if (state.PromiseClientState != null) if (existingSession.PromiseClientState != null)
session.PromiseClientSession = new PromiseClientSession(this.TumblerParameters.CreatePromiseParamaters(), state.PromiseClientState); session.PromiseClientSession = new PromiseClientSession(this.TumblerParameters.CreatePromiseParamaters(), existingSession.PromiseClientState);
if (state.SolverClientState != null) if (existingSession.SolverClientState != null)
session.SolverClientSession = new SolverClientSession(this.TumblerParameters.CreateSolverParamaters(), state.SolverClientState); session.SolverClientSession = new SolverClientSession(this.TumblerParameters.CreateSolverParamaters(), existingSession.SolverClientState);
// update the session // update the session
session.Update(); session.Update();
// replace the updated session in the list of existing sessions // replace the updated session in the list of existing sessions
int index = this.Sessions.IndexOf(state); int index = this.Sessions.IndexOf(existingSession);
if (index != -1) if (index != -1)
{ {
this.Sessions[index] = session; this.Sessions[index] = session;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment