Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Changed formatting of asset, now value and asset symbol are stored se…
Browse files Browse the repository at this point in the history
…parately. #421
  • Loading branch information
vpavliv committed Mar 5, 2018
1 parent 1bb86f7 commit ea9f267
Showing 1 changed file with 60 additions and 53 deletions.
113 changes: 60 additions & 53 deletions plugins/mongo_db/mongo_db_operations.cpp
Expand Up @@ -45,6 +45,13 @@ namespace mongo_db {
return props_doc;
}

document format_asset(const asset& _asset) {
document asset_doc;
asset_doc << "amount" << std::to_string(_asset.to_real())
<< "symbol_name" << _asset.symbol_name();
return asset_doc;
}

std::string to_string(const signature_type& signature) {
std::string retVal;

Expand Down Expand Up @@ -87,8 +94,8 @@ namespace mongo_db {
document body;

body << "from" << op.from
<< "to" << op.to
<< "amount" << op.amount.to_string()
<< "to" << op.to;
body << "amount" << format_asset(op.amount)
<< "memo" << op.memo;

data << "transfer" << body;
Expand All @@ -98,17 +105,17 @@ namespace mongo_db {
document body;

body << "from" << op.from
<< "to" << op.to
<< "amount" << op.amount.to_string();
<< "to" << op.to;
body << "amount" << format_asset(op.amount);

data << "transfer_to_vesting" << body;
}

void operation_writer::operator()(const withdraw_vesting_operation &op) {
document body;

body << "account" << op.account
<< "vesting_shares" << op.vesting_shares.to_string();
body << "account" << op.account;
body << "vesting_shares" << format_asset(op.vesting_shares);

data << "withdraw_vesting" << body;
}
Expand All @@ -117,10 +124,10 @@ namespace mongo_db {
document body;

body << "owner" << op.owner
<< "orderid" << std::to_string(op.orderid)
<< "amount_to_sell" << op.amount_to_sell.to_string()
<< "min_to_receive" << op.min_to_receive.to_string()
<< "expiration" << op.expiration;
<< "orderid" << std::to_string(op.orderid);
body << "amount_to_sell" << format_asset(op.amount_to_sell);
body << "min_to_receive" << format_asset(op.min_to_receive);
body << "expiration" << op.expiration;

body << "limit_order_create" << body;
}
Expand All @@ -147,8 +154,8 @@ namespace mongo_db {
document body;

body << "owner" << op.owner
<< "requestid" << std::to_string(op.requestid)
<< "amount" << op.amount.to_string();
<< "requestid" << std::to_string(op.requestid);
body << "amount" << format_asset(op.amount);

data << "convert" << body;
}
Expand Down Expand Up @@ -394,11 +401,11 @@ namespace mongo_db {
body << "from" << op.from
<< "to" << op.to
<< "agent" << op.agent
<< "escrow_id" << std::to_string(op.escrow_id)
<< "sbd_amount" << op.sbd_amount.to_string()
<< "steem_amount " << op.steem_amount.to_string()
<< "fee" << op.fee.to_string()
<< "json_meta" << op.json_meta;
<< "escrow_id" << std::to_string(op.escrow_id);
body << "sbd_amount" << format_asset(op.sbd_amount);
body << "steem_amount " << format_asset(op.steem_amount);
body << "fee" << format_asset(op.fee);
body << "json_meta" << op.json_meta;

data << "escrow_transfer" << body;
}
Expand All @@ -423,9 +430,9 @@ namespace mongo_db {
<< "agent" << op.agent
<< "who" << op.who
<< "receiver" << op.receiver
<< "escrow_id" << std::to_string(op.escrow_id)
<< "sbd_amount" << op.sbd_amount.to_string()
<< "steem_amount" << op.steem_amount.to_string();
<< "escrow_id" << std::to_string(op.escrow_id);
body << "sbd_amount" << format_asset(op.sbd_amount);
body << "steem_amount" << format_asset(op.steem_amount);

data << "escrow_release" << body;
}
Expand Down Expand Up @@ -458,9 +465,9 @@ namespace mongo_db {
document body;

body << "from" << op.from
<< "to" << op.to
<< "amount" << op.amount.to_string()
<< "memo" << op.memo;
<< "to" << op.to;
body << "amount" << format_asset(op.amount);
body << "memo" << op.memo;

data << "transfer_to_savings" << body;
}
Expand All @@ -469,9 +476,9 @@ namespace mongo_db {
document body;

body << "from" << op.from
<< "to" << op.to
<< "amount" << op.amount.to_string()
<< "memo" << op.memo
<< "to" << op.to;
body << "amount" << format_asset(op.amount);
body << "memo" << op.memo
<< "request_id" << std::to_string(op.request_id);

data << "transfer_from_savings" << body;
Expand Down Expand Up @@ -551,9 +558,9 @@ namespace mongo_db {
document body;

body << "owner" << op.owner
<< "requestid" << std::to_string(op.requestid)
<< "amount_in" << op.amount_in.to_string()
<< "amount_out" << op.amount_out.to_string();
<< "requestid" << std::to_string(op.requestid);
body << "amount_in" << format_asset(op.amount_in);
body << "amount_out" << format_asset(op.amount_out);

data << "fill_convert_request" << body;
}
Expand All @@ -562,20 +569,20 @@ namespace mongo_db {
document body;

body << "author" << op.author
<< "permlink" << op.permlink
<< "sbd_payout" << op.sbd_payout.to_string()
<< "steem_payout" << op.steem_payout.to_string()
<< "vesting_payout" << op.vesting_payout.to_string();
<< "permlink" << op.permlink;
body << "sbd_payout" << format_asset(op.sbd_payout);
body << "steem_payout" << format_asset(op.steem_payout);
body << "vesting_payout" << format_asset(op.vesting_payout);

data << "author_reward" << body;
}

void operation_writer::operator()(const curation_reward_operation &op) {
document body;

body << "curator" << op.curator
<< "reward" << op.reward.to_string()
<< "comment_author" << op.comment_author
body << "curator" << op.curator;
body << "reward" << format_asset(op.reward);
body << "comment_author" << op.comment_author
<< "comment_permlink" << op.comment_permlink;

data << "curation_reward" << body;
Expand All @@ -585,26 +592,26 @@ namespace mongo_db {
document body;

body << "author" << op.author
<< "permlink" << op.permlink
<< "payout" << op.payout.to_string();
<< "permlink" << op.permlink;
body << "payout" << format_asset(op.payout);

data << "comment_reward" << body;
}

void operation_writer::operator()(const liquidity_reward_operation &op) {
document body;

body << "owner" << op.owner
<< "payout" << op.payout.to_string();
body << "owner" << op.owner;
body << "payout" << format_asset(op.payout);

data << "liquidity_reward" << body;
}

void operation_writer::operator()(const interest_operation &op) {
document body;

body << "owner" << op.owner
<< "interest" << op.interest.to_string();
body << "owner" << op.owner;
body << "interest" << format_asset(op.interest);

data << "interest" << body;
}
Expand All @@ -613,9 +620,9 @@ namespace mongo_db {
document body;

body << "from_account" << op.from_account
<< "to_account" << op.to_account
<< "withdrawn" << op.withdrawn.to_string()
<< "deposited" << op.deposited.to_string();
<< "to_account" << op.to_account;
body << "withdrawn" << format_asset(op.withdrawn);
body << "deposited" << format_asset(op.deposited);

data << "fill_vesting_withdraw" << body;
}
Expand All @@ -624,11 +631,11 @@ namespace mongo_db {
document body;

body << "current_owner" << op.current_owner
<< "current_orderid" << std::to_string(op.current_orderid)
<< "current_pays" << op.current_pays.to_string()
<< "open_owner" << op.open_owner
<< "open_orderid" << std::to_string(op.open_orderid)
<< "open_pays" << op.open_pays.to_string();
<< "current_orderid" << std::to_string(op.current_orderid);
body << "current_pays" << format_asset(op.current_pays);
body << "open_owner" << op.open_owner
<< "open_orderid" << std::to_string(op.open_orderid);
body << "open_pays" << format_asset(op.open_pays);

data << "fill_order" << body;
}
Expand All @@ -645,9 +652,9 @@ namespace mongo_db {
document body;

body << "from" << op.from
<< "to" << op.to
<< "amount" << op.amount.to_string()
<< "request_id" << std::to_string(op.request_id)
<< "to" << op.to;
body << "amount" << format_asset(op.amount);
body << "request_id" << std::to_string(op.request_id)
<< "memo" << op.memo;

data << "fill_transfer_from_savings" << body;
Expand Down

0 comments on commit ea9f267

Please sign in to comment.