public new static UnconfirmedBalanceLocator Parse(string str) { var result = BalanceLocator.Parse(str); if (!(result is UnconfirmedBalanceLocator)) { throw InvalidUnconfirmedBalance(); } return((UnconfirmedBalanceLocator)result); }
public new static ConfirmedBalanceLocator Parse(string str) { var result = BalanceLocator.Parse(str); if (!(result is ConfirmedBalanceLocator)) { throw new FormatException("Invalid Confirmed Balance Locator"); } return((ConfirmedBalanceLocator)result); }
public TableQuery CreateTableQuery(string partitionId, string scope) { BalanceLocator from = From ?? new UnconfirmedBalanceLocator(); BalanceLocator to = To ?? new ConfirmedBalanceLocator(0); var toIncluded = ToIncluded; var fromIncluded = FromIncluded; //Fix automatically if wrong order if (!from.IsGreaterThan(to)) { var temp = to; var temp2 = toIncluded; to = from; toIncluded = FromIncluded; from = temp; fromIncluded = temp2; } //// //Complete the balance locator is partial from = fromIncluded ? from.Floor() : from.Ceil(); to = toIncluded ? to.Ceil() : to.Floor(); ///// return(new TableQuery() { FilterString = TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionId), TableOperators.And, TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("RowKey", fromIncluded ? QueryComparisons.GreaterThanOrEqual : QueryComparisons.GreaterThan, scope + "-" + from.ToString(true)), TableOperators.And, TableQuery.GenerateFilterCondition("RowKey", toIncluded ? QueryComparisons.LessThanOrEqual : QueryComparisons.LessThan, scope + "-" + to.ToString(true)) )) }); }
public bool YoungerThan(BalanceLocator to) { if (this is UnconfirmedBalanceLocator && to is ConfirmedBalanceLocator) { return(true); } if (this is ConfirmedBalanceLocator && to is UnconfirmedBalanceLocator) { return(false); } if (this is ConfirmedBalanceLocator && to is ConfirmedBalanceLocator) { var a = (ConfirmedBalanceLocator)this; var b = (ConfirmedBalanceLocator)to; return(a.Height > b.Height); } if (this is UnconfirmedBalanceLocator && to is UnconfirmedBalanceLocator) { var a = (UnconfirmedBalanceLocator)this; var b = (UnconfirmedBalanceLocator)to; return(a.SeenDate > b.SeenDate); } throw new NotSupportedException("should never happen"); }
internal OrderedBalanceChange(DynamicTableEntity entity) { var splitted = entity.RowKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); Height = Helper.StringToHeight(splitted[1]); BalanceId = BalanceId.Parse(splitted[0]); var locator = BalanceLocator.Parse(string.Join("-", splitted.Skip(1).ToArray()), true); var confLocator = locator as ConfirmedBalanceLocator; if (confLocator != null) { Height = confLocator.Height; TransactionId = confLocator.TransactionId; BlockId = confLocator.BlockHash; } var unconfLocator = locator as UnconfirmedBalanceLocator; if (unconfLocator != null) { TransactionId = unconfLocator.TransactionId; } SeenUtc = entity.Properties["s"].DateTime.Value; _SpentOutpoints = Helper.DeserializeList <OutPoint>(Helper.GetEntityProperty(entity, "a")); if (entity.Properties.ContainsKey("b0")) { _SpentCoins = new CoinCollection(Helper.DeserializeList <Spendable>(Helper.GetEntityProperty(entity, "b")).Select(s => new Coin() { Outpoint = s.OutPoint, TxOut = s.TxOut }).ToList()); } else if (_SpentOutpoints.Count == 0) { _SpentCoins = new CoinCollection(); } _SpentIndices = Helper.DeserializeList <IntCompactVarInt>(Helper.GetEntityProperty(entity, "ss")).Select(i => (uint)i.ToLong()).ToList(); var receivedIndices = Helper.DeserializeList <IntCompactVarInt>(Helper.GetEntityProperty(entity, "c")).Select(i => (uint)i.ToLong()).ToList(); var receivedTxOuts = Helper.DeserializeList <TxOut>(Helper.GetEntityProperty(entity, "d")); _ReceivedCoins = new CoinCollection(); for (int i = 0; i < receivedIndices.Count; i++) { _ReceivedCoins.Add(new Coin() { Outpoint = new OutPoint(TransactionId, receivedIndices[i]), TxOut = receivedTxOuts[i] }); } var flags = entity.Properties["e"].StringValue; HasOpReturn = flags[0] == 'o'; IsCoinbase = flags[1] == 'o'; _MatchedRules = Helper.DeserializeObject <List <MatchedRule> >(entity.Properties["f"].StringValue).ToList(); if (entity.Properties.ContainsKey("g")) { var ctx = new ColoredTransaction(); ctx.FromBytes(entity.Properties["g"].BinaryValue); ColoredTransaction = ctx; } if (entity.Properties.ContainsKey("h")) { _ScriptPubKey = new Script(entity.Properties["h"].BinaryValue); } var data = Helper.GetEntityProperty(entity, "cu"); if (data != null) { CustomData = Encoding.UTF8.GetString(data); } }
public bool IsGreaterThan(BalanceLocator to) { var result = string.Compare(ToString(true), to.ToString(true)); return(result < 1); }
public bool IsGreaterThan(BalanceLocator to) { var result = string.Compare(ToString(true), to.ToString(true)); return result < 1; }