void HandleSyncFetchRequest(NetworkPacket packet) { TransactionSyncRequest TSR = new TransactionSyncRequest(); TSR.Deserialize(packet.Data); if (nodeState.NodeInfo.LastLedgerInfo.SequenceNumber >= (TSR.StartSequenceNumber + TSR.Length)) { TransactionSyncResponse transactionSyncResponse = new TransactionSyncResponse(); if (nodeState.PersistentTransactionStore.FetchBySequenceNumber(out transactionSyncResponse.TransactionContents, TSR.StartSequenceNumber, TSR.Length) == DBResponse.FetchSuccess) { NetworkPacket np = new NetworkPacket(new Hash(nodeState.NodeInfo.PublicKey), PacketType.TPT_TX_SYNC_FETCH_RESPONSE, transactionSyncResponse.Serialize(), packet.Token); network.AddToQueue(new NetworkPacketQueueEntry(packet.PublicKeySource, np)); // Send the reply. } } }
void HandleSyncFetchResponse(NetworkPacket packet) { TransactionSyncResponse transactionSyncResponse = new TransactionSyncResponse(); transactionSyncResponse.Deserialize(packet.Data); // Verify the correctness and push to database. // CRITICAL. THIS VESION TRUSTS THE SERVER (May not be true in practice) nodeState.PersistentTransactionStore.AddUpdateBatch(transactionSyncResponse.TransactionContents); /*foreach (TransactionContentSet transactionContentSet in transactionSyncResponse.TransactionContents) { // CRITICAL: VERIFY that the transactions are actually valid. Or from fully trusted sources. foreach (TransactionContent transactionContent in transactionContentSet.TxContent) { try { } catch (Exception ex) { DisplayUtils.Display("AddUpdateBatch()", ex); } } }*/ }