public bool AllAlices(AliceState state) { using (RoundSyncronizerLock.Lock()) { return(Alices.All(x => x.State == state)); } }
public IEnumerable <Alice> GetAlicesBy(AliceState state) { using (RoundSyncronizerLock.Lock()) { return(Alices.Where(x => x.State == state).ToList()); } }
public IEnumerable <Alice> GetAlicesByNot(AliceState state, bool syncLock = true) { if (syncLock) { using (RoundSyncronizerLock.Lock()) { return(Alices.Where(x => x.State != state).ToList()); } } return(Alices.Where(x => x.State != state).ToList()); }
public Alice(IEnumerable <Coin> inputs, Money networkFeeToPay, BitcoinAddress changeOutputAddress, string blindedOutputScriptHex) { Inputs = Guard.NotNullOrEmpty(nameof(inputs), inputs); NetworkFeeToPay = Guard.NotNull(nameof(networkFeeToPay), networkFeeToPay); BlindedOutputScriptHex = Guard.NotNullOrEmptyOrWhitespace(nameof(blindedOutputScriptHex), blindedOutputScriptHex); ChangeOutputAddress = Guard.NotNull(nameof(changeOutputAddress), changeOutputAddress); LastSeen = DateTimeOffset.UtcNow; UniqueId = Guid.NewGuid(); InputSum = inputs.Sum(x => x.Amount); OutputSumWithoutCoordinatorFeeAndDenomination = InputSum - NetworkFeeToPay; State = AliceState.InputsRegistered; }
public int RemoveAlicesBy(AliceState state) { int numberOfRemovedAlices = 0; using (RoundSyncronizerLock.Lock()) { if ((Phase != CcjRoundPhase.InputRegistration && Phase != CcjRoundPhase.ConnectionConfirmation) || Status != CcjRoundStatus.Running) { throw new InvalidOperationException("Removing Alice is only allowed in InputRegistration and ConnectionConfirmation phases."); } numberOfRemovedAlices = Alices.RemoveAll(x => x.State == state); } if (numberOfRemovedAlices != 0) { Logger.LogInfo <CcjRound>($"Round ({RoundId}): {numberOfRemovedAlices} alices in {state} state are removed."); } return(numberOfRemovedAlices); }