common/coin_mvt: make more fields const, reorder fields.
Make the common fields the first ones, and make part_and_group and payment_hash const pointers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -90,9 +90,11 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx,
|
||||
assert(!group_id);
|
||||
mvt->part_and_group = NULL;
|
||||
} else {
|
||||
mvt->part_and_group = tal(mvt, struct channel_coin_mvt_id);
|
||||
mvt->part_and_group->part_id = *part_id;
|
||||
mvt->part_and_group->group_id = *group_id;
|
||||
/* Temporary for non-const */
|
||||
struct channel_coin_mvt_id *pg;
|
||||
mvt->part_and_group = pg = tal(mvt, struct channel_coin_mvt_id);
|
||||
pg->part_id = *part_id;
|
||||
pg->group_id = *group_id;
|
||||
}
|
||||
|
||||
mvt->tags = tal_dup_talarr(mvt, enum mvt_tag, tags);
|
||||
@@ -478,8 +480,9 @@ void fromwire_chain_coin_mvt(const u8 **cursor, size_t *max, struct chain_coin_m
|
||||
mvt->tx_txid = NULL;
|
||||
|
||||
if (fromwire_bool(cursor, max)) {
|
||||
mvt->payment_hash = tal(mvt, struct sha256);
|
||||
fromwire_sha256(cursor, max, mvt->payment_hash);
|
||||
struct sha256 *ph;
|
||||
mvt->payment_hash = ph = tal(mvt, struct sha256);
|
||||
fromwire_sha256(cursor, max, ph);
|
||||
} else
|
||||
mvt->payment_hash = NULL;
|
||||
mvt->blockheight = fromwire_u32(cursor, max);
|
||||
|
||||
@@ -56,23 +56,20 @@ struct mvt_account_id {
|
||||
};
|
||||
|
||||
struct channel_coin_mvt {
|
||||
/* account_id */
|
||||
/* Common fields */
|
||||
struct mvt_account_id account;
|
||||
|
||||
/* identifier */
|
||||
struct sha256 *payment_hash;
|
||||
|
||||
/* multi-part payments may share a payment hash,
|
||||
* so we should also record part-id and group-id for them */
|
||||
struct channel_coin_mvt_id *part_and_group;
|
||||
|
||||
/* label / tag array */
|
||||
enum mvt_tag *tags;
|
||||
|
||||
/* only one or the other */
|
||||
struct amount_msat credit;
|
||||
struct amount_msat debit;
|
||||
|
||||
/* identifier */
|
||||
const struct sha256 *payment_hash;
|
||||
|
||||
/* multi-part payments may share a payment hash,
|
||||
* so we should also record part-id and group-id for them */
|
||||
const struct channel_coin_mvt_id *part_and_group;
|
||||
|
||||
/* Fees collected (or paid) on this mvt */
|
||||
struct amount_msat fees;
|
||||
};
|
||||
@@ -80,6 +77,11 @@ struct channel_coin_mvt {
|
||||
struct chain_coin_mvt {
|
||||
/* account_id */
|
||||
struct mvt_account_id account;
|
||||
enum mvt_tag *tags;
|
||||
/* only one or the other */
|
||||
struct amount_msat credit;
|
||||
struct amount_msat debit;
|
||||
|
||||
const struct bitcoin_txid *tx_txid;
|
||||
const struct bitcoin_outpoint *outpoint;
|
||||
|
||||
@@ -88,18 +90,11 @@ struct chain_coin_mvt {
|
||||
const struct node_id *peer_id;
|
||||
|
||||
/* some on-chain movements have a payment hash */
|
||||
struct sha256 *payment_hash;
|
||||
|
||||
/* label / tag array */
|
||||
enum mvt_tag *tags;
|
||||
const struct sha256 *payment_hash;
|
||||
|
||||
/* block this transaction is confirmed in */
|
||||
u32 blockheight;
|
||||
|
||||
/* only one or the other */
|
||||
struct amount_msat credit;
|
||||
struct amount_msat debit;
|
||||
|
||||
/* total value of output (useful for tracking external outs) */
|
||||
struct amount_sat output_val;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user