Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void addTranscation(unsigned senderId,unsigned receiverId,double fmiCoins)
- {
- Wallet sender;
- Wallet receiver;
- Transaction trans;
- trans.senderId = senderId;
- trans.receiverId = receiverId;
- trans.fmiCoins = fmiCoins;
- trans.time = time(NULL);
- fstream myTransactions;
- myTransactions.open(transactionsDirectory, ios::out | ios::app | ios::binary);
- myTransactions.write((const char*)&trans, sizeof(Transaction));
- myTransactions.close();
- fstream myWallet;
- myWallet.open(walletsDirectory, ios::in | ios::out | ios::binary);
- myWallet.seekg((senderId - 1) * sizeof(Wallet), ios::beg);
- myWallet.read((char*)&sender,sizeof(Wallet));
- sender.fiatMoney += 375 * fmiCoins;
- myWallet.seekp((senderId - 1) * sizeof(Wallet), ios::beg);
- myWallet.write((const char*)&sender, sizeof(Wallet));
- myWallet.seekg((receiverId - 1) * sizeof(Wallet), ios::beg);
- receiver.fiatMoney -= 375 * fmiCoins;
- myWallet.seekp((senderId - 1) * sizeof(Wallet), ios::beg);
- myWallet.write((const char*)&receiver, sizeof(Wallet));
- myWallet.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement