private void BtnEdit_Click(object sender, EventArgs e) { try { var data = ((BindingSource)dvTransactions.DataSource).List; TransactionSet currentTransaction = null; int id = int.Parse(dvTransactions.Rows[selectedRowIndex].Cells[0].Value.ToString()); foreach (TransactionSet trans in data) { if (trans.Id == id) { currentTransaction = trans; break; } } TransactionsUpsert transactionsUpsert = new TransactionsUpsert(db, currentTransaction); transactionsUpsert.InitializeManageTransaction(this); transactionsUpsert.ShowDialog(); } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Failed to edit transaction."); } }
private void ReconcileTransactionSet(TransactionSet transSet) { List <ReconciledItem> reconciledItemList = new List <ReconciledItem>(); foreach (var ruleEvaluator in _ruleSetEvaulators.Where(rule => rule.RuleType == ReconciledMatchType.Matched)) { foreach (var cTrans in transSet.ClientSet.ToList()) { foreach (var tTrans in transSet.BankSet.ToList()) { ReconciledItem currentResult = ruleEvaluator.Evaluate(cTrans, tTrans); if (currentResult.MatchType == ReconciledMatchType.Matched) { reconciledItemList.Add(currentResult); transSet.RemoveTransactions(currentResult.ClientTransaction, currentResult.BankTransaction); } } } } if (!transSet.IsReconciled) { _result.Add(new ReconciledItem(transSet, ReconciledMatchType.NotMatched)); } _result.AddItems(reconciledItemList); }
/// <summary> /// Writes a message to the destination. /// </summary> /// <param name="message">The message to write.</param> public override void Write(EdiMessage message) { if (_separators == null) { throw new Exception("No interchange was started."); } _messageCounter++; var segmentCounter = 0; var transactionSet = new TransactionSet(message.GetStandardType(), message); transactionSet.RemoveTrailer(MessageTrailer); foreach (var segment in transactionSet.Descendants <Segment>()) { Write(segment.Generate(_separators, PreserveWhitespace)); segmentCounter++; } if (message.Name == "TA1") { return; } segmentCounter++; var trailer = BuildTrailer(MessageTrailer, message.ControlNumber, segmentCounter); Write(trailer); }
// creates hashed transaction set. Each string in transaction is converted into the interger equivalent of it // hashmap created with unique set of items is used to transaction hashing public List <TransactionSet> GenerateHashedTransactionSet(List <HashMap> hashedItems, List <string> source) { if (source.Count() != 0 && hashedItems.Count() != 0) { int transactionId = 0; foreach (var s in source) { transactionId++; TransactionSet ts = new TransactionSet(); ts.Values = new List <int>(); List <string> srcStringList = s.Split().ToList(); if (srcStringList.Count() != 0) { foreach (var str in srcStringList) { var searchedItem = hashedItems.Where(h => h.UniqueString == str).FirstOrDefault(); ts.TransactionID = transactionId; ts.Values.Add(searchedItem.Order); } ts.Values.Sort(); transactionSet.Add(ts); } } } var x = transactionSet; return(transactionSet); }
public Blockchain(IStore store) { Store = store; Blocks = new BlockSet <T>(store); Transactions = new TransactionSet <T>(store); Addresses = new AddressTransactionSet <T>(store); }
public static void Encode(XdrDataOutputStream stream, LedgerCloseMetaV0 encodedLedgerCloseMetaV0) { LedgerHeaderHistoryEntry.Encode(stream, encodedLedgerCloseMetaV0.LedgerHeader); TransactionSet.Encode(stream, encodedLedgerCloseMetaV0.TxSet); int txProcessingsize = encodedLedgerCloseMetaV0.TxProcessing.Length; stream.WriteInt(txProcessingsize); for (int i = 0; i < txProcessingsize; i++) { TransactionResultMeta.Encode(stream, encodedLedgerCloseMetaV0.TxProcessing[i]); } int upgradesProcessingsize = encodedLedgerCloseMetaV0.UpgradesProcessing.Length; stream.WriteInt(upgradesProcessingsize); for (int i = 0; i < upgradesProcessingsize; i++) { UpgradeEntryMeta.Encode(stream, encodedLedgerCloseMetaV0.UpgradesProcessing[i]); } int scpInfosize = encodedLedgerCloseMetaV0.ScpInfo.Length; stream.WriteInt(scpInfosize); for (int i = 0; i < scpInfosize; i++) { SCPHistoryEntry.Encode(stream, encodedLedgerCloseMetaV0.ScpInfo[i]); } }
public static LedgerCloseMetaV0 Decode(XdrDataInputStream stream) { LedgerCloseMetaV0 decodedLedgerCloseMetaV0 = new LedgerCloseMetaV0(); decodedLedgerCloseMetaV0.LedgerHeader = LedgerHeaderHistoryEntry.Decode(stream); decodedLedgerCloseMetaV0.TxSet = TransactionSet.Decode(stream); int txProcessingsize = stream.ReadInt(); decodedLedgerCloseMetaV0.TxProcessing = new TransactionResultMeta[txProcessingsize]; for (int i = 0; i < txProcessingsize; i++) { decodedLedgerCloseMetaV0.TxProcessing[i] = TransactionResultMeta.Decode(stream); } int upgradesProcessingsize = stream.ReadInt(); decodedLedgerCloseMetaV0.UpgradesProcessing = new UpgradeEntryMeta[upgradesProcessingsize]; for (int i = 0; i < upgradesProcessingsize; i++) { decodedLedgerCloseMetaV0.UpgradesProcessing[i] = UpgradeEntryMeta.Decode(stream); } int scpInfosize = stream.ReadInt(); decodedLedgerCloseMetaV0.ScpInfo = new SCPHistoryEntry[scpInfosize]; for (int i = 0; i < scpInfosize; i++) { decodedLedgerCloseMetaV0.ScpInfo[i] = SCPHistoryEntry.Decode(stream); } return(decodedLedgerCloseMetaV0); }
public TransactionSetTest() { _fx = new FileStoreFixture(); _set = new TransactionSet <BaseAction>( _fx.Store, _fx.StoreNamespace ); }
public static void Encode(IByteWriter stream, TransactionSet encodedTransactionSet) { Hash.Encode(stream, encodedTransactionSet.PreviousLedgerHash); int txssize = encodedTransactionSet.Txs.Length; XdrEncoding.EncodeInt32(txssize, stream); for (int i = 0; i < txssize; i++) { TransactionEnvelope.Encode(stream, encodedTransactionSet.Txs[i]); } }
public TransactionsUpsert(DatabaseModelContainer db, TransactionSet updatingTransaction) { this.db = db; currentEditingTransaction = updatingTransaction; InitializeComponent(); LoadInitialData(); }
public override void Write(EdiMessage message) { var transactionSet = new TransactionSet(message.GetStandardType(), message); foreach (var segment in transactionSet.Descendants <Segment>()) { Write(segment.Generate(Pad)); } }
public static TransactionHistoryEntry Decode(XdrDataInputStream stream) { var decodedTransactionHistoryEntry = new TransactionHistoryEntry(); decodedTransactionHistoryEntry.LedgerSeq = Uint32.Decode(stream); decodedTransactionHistoryEntry.TxSet = TransactionSet.Decode(stream); decodedTransactionHistoryEntry.Ext = TransactionHistoryEntryExt.Decode(stream); return(decodedTransactionHistoryEntry); }
public static TransactionHistoryEntry Decode(IByteReader stream) { TransactionHistoryEntry decodedTransactionHistoryEntry = new TransactionHistoryEntry(); decodedTransactionHistoryEntry.LedgerSeq = Uint32.Decode(stream); decodedTransactionHistoryEntry.TxSet = TransactionSet.Decode(stream); decodedTransactionHistoryEntry.Ext = TransactionHistoryEntryExt.Decode(stream); return(decodedTransactionHistoryEntry); }
public static TransactionSet Decode(IByteReader stream) { TransactionSet decodedTransactionSet = new TransactionSet(); decodedTransactionSet.PreviousLedgerHash = Hash.Decode(stream); int txssize = XdrEncoding.DecodeInt32(stream); decodedTransactionSet.Txs = new TransactionEnvelope[txssize]; for (int i = 0; i < txssize; i++) { decodedTransactionSet.Txs[i] = TransactionEnvelope.Decode(stream); } return decodedTransactionSet; }
public static void Encode(IByteWriter stream, TransactionSet encodedTransactionSet) { Hash.Encode(stream, encodedTransactionSet.PreviousLedgerHash); int txssize = encodedTransactionSet.Txs.Length; XdrEncoding.EncodeInt32(txssize, stream); for (int i = 0; i < txssize; i++) { TransactionEnvelope.Encode(stream, encodedTransactionSet.Txs[i]); } }
public BlockChain(IBlockPolicy <T> policy, IStore store, Guid id) { Id = id; Policy = policy; Store = store; Blocks = new BlockSet <T>(store); Transactions = new TransactionSet <T>(store); _rwlock = new ReaderWriterLockSlim( LockRecursionPolicy.SupportsRecursion); }
public BlockChain(IBlockPolicy <T> policy, IStore store, Guid id) { _id = id; Policy = policy; Store = store; Blocks = new BlockSet <T>(store, _id.ToString()); Transactions = new TransactionSet <T>(store, _id.ToString()); Addresses = new AddressTransactionSet <T>(store, _id.ToString()); Store.InitNamespace(_id.ToString()); }
public static void Encode(XdrDataOutputStream stream, TransactionSet encodedTransactionSet) { Hash.Encode(stream, encodedTransactionSet.PreviousLedgerHash); var txssize = encodedTransactionSet.Txs.Length; stream.WriteInt(txssize); for (var i = 0; i < txssize; i++) { TransactionEnvelope.Encode(stream, encodedTransactionSet.Txs[i]); } }
public static TransactionSet Decode(XdrDataInputStream stream) { var decodedTransactionSet = new TransactionSet(); decodedTransactionSet.PreviousLedgerHash = Hash.Decode(stream); var txssize = stream.ReadInt(); decodedTransactionSet.Txs = new TransactionEnvelope[txssize]; for (var i = 0; i < txssize; i++) { decodedTransactionSet.Txs[i] = TransactionEnvelope.Decode(stream); } return(decodedTransactionSet); }
public static TransactionSet Decode(IByteReader stream) { TransactionSet decodedTransactionSet = new TransactionSet(); decodedTransactionSet.PreviousLedgerHash = Hash.Decode(stream); int txssize = XdrEncoding.DecodeInt32(stream); decodedTransactionSet.Txs = new TransactionEnvelope[txssize]; for (int i = 0; i < txssize; i++) { decodedTransactionSet.Txs[i] = TransactionEnvelope.Decode(stream); } return(decodedTransactionSet); }
// FIXME it's very dangerous because replacing Id means // ALL blocks (referenced by MineBlock(), etc.) will be changed. // we need to add a synchronization mechanism to handle this correctly. internal void Swap(BlockChain <T> other) { try { _rwlock.EnterWriteLock(); Id = other.Id; Blocks = new BlockSet <T>(Store); Transactions = new TransactionSet <T>(Store); } finally { _rwlock.ExitWriteLock(); } }
// FIXME it's very dangerous because replacing Id means // ALL blocks (referenced by MineBlock(), etc.) will be changed. // we need to add a synchronization mechanism to handle this correctly. internal void Swap(BlockChain <T> other) { try { _rwlock.EnterWriteLock(); Id = other.Id; Blocks = new BlockSet <T>(Store, Id.ToString()); Transactions = new TransactionSet <T>(Store, Id.ToString()); Addresses = new AddressTransactionSet <T>(Store, Id.ToString()); } finally { _rwlock.ExitWriteLock(); } }
internal BlockChain(IBlockPolicy <T> policy, IStore store, Guid id) { Id = id; Policy = policy; Store = store; Blocks = new BlockSet <T>(store); Transactions = new TransactionSet <T>(store); _rwlock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); _txLock = new object(); if (Store.GetCanonicalChainId() is null) { Store.SetCanonicalChainId(Id); } }
/// <summary> /// Parses the accumulated segments. /// </summary> protected EdiItem ParseSegments() { if (CurrentMessageContext == null) { CurrentSegments.Clear(); return(null); } EdiItem result; try { var message = new TransactionSet(CurrentMessageContext.MessageType); var errorContext = message.Analyze(CurrentSegments, CurrentMessageContext, Separators, PartsIndex, SegmentIndex); var ediMessage = (EdiMessage)message.ToInstance(); ediMessage.MessagePart = PartsIndex; ediMessage.ControlNumber = CurrentMessageContext.ControlNumber; ediMessage.ErrorContext = errorContext; result = ediMessage; } catch (Exception ex) { result = new ReaderErrorContext(ex, ReaderErrorCode.InvalidSpecOrAssembly, new MessageErrorContext(CurrentMessageContext.Name, CurrentMessageContext.ControlNumber, CurrentMessageContext.Version, PartsIndex, ex.Message, MessageErrorCode.MissingOrInvalidTransactionSet)); } finally { SegmentIndex = SegmentIndex + CurrentSegments.Count; CurrentSegments.Clear(); } return(result); }
// FIXME it's very dangerous because replacing Id means // ALL blocks (referenced by MineBlock(), etc.) will be changed. // we need to add a synchronization mechanism to handle this correctly. internal void Swap(BlockChain <T> other, bool render) { // Finds the branch point. Block <T> topmostCommon = null; if (render && !(Tip is null || other.Tip is null)) { long shorterHeight = Math.Min(this.LongCount(), other.LongCount()) - 1; for ( Block <T> t = this[shorterHeight], o = other[shorterHeight]; t.PreviousHash is HashDigest <SHA256> tp && o.PreviousHash is HashDigest <SHA256> op; t = Blocks[tp], o = other.Blocks[op] ) { if (t.Equals(o)) { topmostCommon = t; break; } } } if (render) { // Unrender stale actions. for ( Block <T> b = Tip; !(b is null) && b.Index > (topmostCommon?.Index ?? -1) && b.PreviousHash is HashDigest <SHA256> ph; b = Blocks[ph] ) { List <ActionEvaluation> evaluations = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a)) .Select(te => te.Item2).ToList(); if (Policy.BlockAction is IAction) { evaluations.Add(EvaluateBlockAction(b, evaluations)); } evaluations.Reverse(); foreach (var evaluation in evaluations) { evaluation.Action.Unrender( evaluation.InputContext, evaluation.OutputStates ); } } } try { _rwlock.EnterWriteLock(); var tipChangedEventArgs = new TipChangedEventArgs { PreviousHash = Tip?.Hash, PreviousIndex = Tip?.Index, Hash = other.Tip.Hash, Index = other.Tip.Index, }; Guid obsoleteId = Id; Id = other.Id; Store.SetCanonicalChainId(Id); Blocks = new BlockSet <T>(Store); TipChanged?.Invoke(this, tipChangedEventArgs); Transactions = new TransactionSet <T>(Store); Store.DeleteChainId(obsoleteId); } finally { _rwlock.ExitWriteLock(); } if (render) { // Render actions that had been behind. IEnumerable <Block <T> > blocksToRender = topmostCommon is Block <T> branchPoint ? this.SkipWhile(b => b.Index <= branchPoint.Index) : this; foreach (Block <T> b in blocksToRender) { List <ActionEvaluation> evaluations = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a)) .Select(te => te.Item2).ToList(); if (Policy.BlockAction is IAction) { evaluations.Add(EvaluateBlockAction(b, evaluations)); } foreach (var evaluation in evaluations) { evaluation.Action.Render( evaluation.InputContext, evaluation.OutputStates ); } } } }
public TransactionSetTest() { _fx = new DefaultStoreFixture(); _set = new TransactionSet <DumbAction>(_fx.Store); }
// FIXME it's very dangerous because replacing Id means // ALL blocks (referenced by MineBlock(), etc.) will be changed. // we need to add a synchronization mechanism to handle this correctly. internal void Swap(BlockChain <T> other) { // Finds the branch point. Block <T> topmostCommon = null; long shorterHeight = Math.Min(this.LongCount(), other.LongCount()) - 1; for ( Block <T> t = this[shorterHeight], o = other[shorterHeight]; t.PreviousHash is HashDigest <SHA256> tp && o.PreviousHash is HashDigest <SHA256> op; t = Blocks[tp], o = other.Blocks[op] ) { if (t.Equals(o)) { topmostCommon = t; break; } } // Unrender stale actions. for ( Block <T> b = Tip; !(b is null) && b.Index > (topmostCommon?.Index ?? -1) && b.PreviousHash is HashDigest <SHA256> ph; b = Blocks[ph] ) { var actions = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a) ).Reverse(); foreach (var(_, evaluation) in actions) { evaluation.Action.Unrender( evaluation.InputContext, evaluation.OutputStates ); } } try { _rwlock.EnterWriteLock(); Id = other.Id; Blocks = new BlockSet <T>(Store); Transactions = new TransactionSet <T>(Store); } finally { _rwlock.ExitWriteLock(); } // Render actions that had been behind. IEnumerable <Block <T> > blocksToRender = topmostCommon is Block <T> branchPoint ? this.SkipWhile(b => b.Index <= branchPoint.Index) : this; foreach (Block <T> b in blocksToRender) { var actions = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a) ); foreach (var(_, evaluation) in actions) { evaluation.Action.Render( evaluation.InputContext, evaluation.OutputStates ); } } }
public void UpdateTransactionSet(TransactionSet transactionSet) { this.DataProvider.Update(transactionSet); }
public static void Encode(XdrDataOutputStream stream, StellarMessage encodedStellarMessage) { stream.WriteInt((int)encodedStellarMessage.Discriminant.InnerValue); switch (encodedStellarMessage.Discriminant.InnerValue) { case MessageType.MessageTypeEnum.ERROR_MSG: Error.Encode(stream, encodedStellarMessage.Error); break; case MessageType.MessageTypeEnum.HELLO: Hello.Encode(stream, encodedStellarMessage.Hello); break; case MessageType.MessageTypeEnum.AUTH: Auth.Encode(stream, encodedStellarMessage.Auth); break; case MessageType.MessageTypeEnum.DONT_HAVE: DontHave.Encode(stream, encodedStellarMessage.DontHave); break; case MessageType.MessageTypeEnum.GET_PEERS: break; case MessageType.MessageTypeEnum.PEERS: int peerssize = encodedStellarMessage.Peers.Length; stream.WriteInt(peerssize); for (int i = 0; i < peerssize; i++) { PeerAddress.Encode(stream, encodedStellarMessage.Peers[i]); } break; case MessageType.MessageTypeEnum.GET_TX_SET: Uint256.Encode(stream, encodedStellarMessage.TxSetHash); break; case MessageType.MessageTypeEnum.TX_SET: TransactionSet.Encode(stream, encodedStellarMessage.TxSet); break; case MessageType.MessageTypeEnum.TRANSACTION: TransactionEnvelope.Encode(stream, encodedStellarMessage.Transaction); break; case MessageType.MessageTypeEnum.GET_SCP_QUORUMSET: Uint256.Encode(stream, encodedStellarMessage.QSetHash); break; case MessageType.MessageTypeEnum.SCP_QUORUMSET: SCPQuorumSet.Encode(stream, encodedStellarMessage.QSet); break; case MessageType.MessageTypeEnum.SCP_MESSAGE: SCPEnvelope.Encode(stream, encodedStellarMessage.Envelope); break; case MessageType.MessageTypeEnum.GET_SCP_STATE: Uint32.Encode(stream, encodedStellarMessage.GetSCPLedgerSeq); break; } }
public static StellarMessage Decode(XdrDataInputStream stream) { StellarMessage decodedStellarMessage = new StellarMessage(); MessageType discriminant = MessageType.Decode(stream); decodedStellarMessage.Discriminant = discriminant; switch (decodedStellarMessage.Discriminant.InnerValue) { case MessageType.MessageTypeEnum.ERROR_MSG: decodedStellarMessage.Error = Error.Decode(stream); break; case MessageType.MessageTypeEnum.HELLO: decodedStellarMessage.Hello = Hello.Decode(stream); break; case MessageType.MessageTypeEnum.AUTH: decodedStellarMessage.Auth = Auth.Decode(stream); break; case MessageType.MessageTypeEnum.DONT_HAVE: decodedStellarMessage.DontHave = DontHave.Decode(stream); break; case MessageType.MessageTypeEnum.GET_PEERS: break; case MessageType.MessageTypeEnum.PEERS: int peerssize = stream.ReadInt(); decodedStellarMessage.Peers = new PeerAddress[peerssize]; for (int i = 0; i < peerssize; i++) { decodedStellarMessage.Peers[i] = PeerAddress.Decode(stream); } break; case MessageType.MessageTypeEnum.GET_TX_SET: decodedStellarMessage.TxSetHash = Uint256.Decode(stream); break; case MessageType.MessageTypeEnum.TX_SET: decodedStellarMessage.TxSet = TransactionSet.Decode(stream); break; case MessageType.MessageTypeEnum.TRANSACTION: decodedStellarMessage.Transaction = TransactionEnvelope.Decode(stream); break; case MessageType.MessageTypeEnum.GET_SCP_QUORUMSET: decodedStellarMessage.QSetHash = Uint256.Decode(stream); break; case MessageType.MessageTypeEnum.SCP_QUORUMSET: decodedStellarMessage.QSet = SCPQuorumSet.Decode(stream); break; case MessageType.MessageTypeEnum.SCP_MESSAGE: decodedStellarMessage.Envelope = SCPEnvelope.Decode(stream); break; case MessageType.MessageTypeEnum.GET_SCP_STATE: decodedStellarMessage.GetSCPLedgerSeq = Uint32.Decode(stream); break; } return(decodedStellarMessage); }
public void DeleteTransactionSet(TransactionSet transactionSet) { this._helper.DeleteDomainObject(transactionSet); }
public void AddTransactionSet(TransactionSet transactionSet) { this._helper.AddDomainObject(transactionSet); }