MCPcopy Create free account
hub / github.com/bcndev/bytecoin / modify_balance

Method modify_balance

src/Core/WalletStateBasic.cpp:855–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853}
854
855void WalletStateBasic::modify_balance(const api::Output &output, int locked_op, int spendable_op) {
856 auto bakey = INDEX_ADDRESS_to_BALANCE + output.address;
857 auto bakey2 = INDEX_ADDRESS_to_BALANCE;
858 BinaryArray ba;
859 api::Balance balance;
860 api::Balance balance2;
861 if (m_db.get(bakey, ba))
862 seria::from_binary(balance, ba);
863 if (m_db.get(bakey2, ba))
864 seria::from_binary(balance2, ba);
865 // std::cout << "modify_balance " << output.amount << " locked_op=" <<
866 // locked_op << " spendable_op=" << spendable_op << std::endl;
867 combine_balance(balance, output, locked_op, spendable_op);
868 combine_balance(balance2, output, locked_op, spendable_op);
869 if (balance.total() == 0 && balance.total_outputs() == 0)
870 del_with_undo(bakey, false);
871 else
872 put_with_undo(bakey, seria::to_binary(balance), false);
873 if (balance2.total() == 0 && balance2.total_outputs() == 0)
874 del_with_undo(bakey2, false);
875 else
876 put_with_undo(bakey2, seria::to_binary(balance2), false);
877}
878
879static const std::map<KeyImage, std::vector<Hash>> empty_kis_or_pks;
880const std::map<KeyImage, std::vector<Hash>> &WalletStateBasic::get_mempool_keyimages() const {

Callers

nothing calls this directly

Calls 5

from_binaryFunction · 0.85
to_binaryFunction · 0.85
totalMethod · 0.80
total_outputsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected