peer.c, packets.c: make more functions static.

This also has to re-order functions, so it looks worse than it is. 

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-08-18 14:23:45 +09:30
parent 0bd12b4e97
commit 08f7ade80f
4 changed files with 482 additions and 526 deletions

View File

@ -9,9 +9,6 @@ struct sha256;
struct bitcoin_signature; struct bitcoin_signature;
struct commit_info; struct commit_info;
/* Inform peer have an unexpected packet. */
void peer_unexpected_pkt(struct peer *peer, const Pkt *pkt);
/* Send various kinds of packets */ /* Send various kinds of packets */
void queue_pkt_open(struct peer *peer, OpenChannel__AnchorOffer anchor); void queue_pkt_open(struct peer *peer, OpenChannel__AnchorOffer anchor);
void queue_pkt_anchor(struct peer *peer); void queue_pkt_anchor(struct peer *peer);

File diff suppressed because it is too large Load Diff

View File

@ -224,35 +224,9 @@ struct peer *find_peer(struct lightningd_state *dstate, const struct pubkey *id)
/* Populates very first peer->{local,remote}.commit->{tx,cstate} */ /* Populates very first peer->{local,remote}.commit->{tx,cstate} */
bool setup_first_commit(struct peer *peer); bool setup_first_commit(struct peer *peer);
/* Set up timer: we have something we can commit. */
void remote_changes_pending(struct peer *peer);
/* Add this unacked change */
void add_unacked(struct peer_visible_state *which,
const union htlc_staging *stage);
/* These unacked changes are now acked; add them to acked set. */
void add_acked_changes(union htlc_staging **acked,
const union htlc_staging *changes);
/* Both sides are committed to these changes they proposed. */
void peer_both_committed_to(struct peer *peer,
const union htlc_staging *changes, enum channel_side side);
/* Allocate a new commit_info struct. */ /* Allocate a new commit_info struct. */
struct commit_info *new_commit_info(const tal_t *ctx); struct commit_info *new_commit_info(const tal_t *ctx);
struct state_table {
enum htlc_state from, to;
};
bool htlcs_changestate(struct peer *peer,
const struct state_table *table, size_t n);
void apply_changeset(struct peer *peer,
struct peer_visible_state *which,
enum channel_side side,
const union htlc_staging *changes,
size_t num_changes);
/* Freeing removes from map, too */ /* Freeing removes from map, too */
struct htlc *peer_new_htlc(struct peer *peer, struct htlc *peer_new_htlc(struct peer *peer,
u64 id, u64 id,
@ -270,19 +244,12 @@ struct htlc *command_htlc_add(struct peer *peer, u64 msatoshis,
struct htlc *src, struct htlc *src,
const u8 *route); const u8 *route);
/* Peer has recieved revocation. */ void peer_unexpected_pkt(struct peer *peer, const Pkt *pkt);
void peer_update_complete(struct peer *peer);
/* Peer has completed open, or problem (if non-NULL). */ /* Peer has completed open, or problem (if non-NULL). */
void peer_open_complete(struct peer *peer, const char *problem); void peer_open_complete(struct peer *peer, const char *problem);
struct bitcoin_tx *peer_create_close_tx(struct peer *peer, u64 fee); struct bitcoin_tx *peer_create_close_tx(struct peer *peer, u64 fee);
uint64_t commit_tx_fee(const struct bitcoin_tx *commit,
uint64_t anchor_satoshis);
void our_htlc_fulfilled(struct peer *peer, struct htlc *htlc,
const struct rval *preimage);
void cleanup_peers(struct lightningd_state *dstate); void cleanup_peers(struct lightningd_state *dstate);
#endif /* LIGHTNING_DAEMON_PEER_H */ #endif /* LIGHTNING_DAEMON_PEER_H */

21
state.h
View File

@ -115,29 +115,14 @@ void peer_unwatch_anchor_depth(struct peer *peer,
enum state_input depthok, enum state_input depthok,
enum state_input timeout); enum state_input timeout);
/**
* peer_calculate_close_fee: figure out what the fee for closing is.
* @peer: the state data for this peer.
*/
void peer_calculate_close_fee(struct peer *peer);
/* Start creation of the bitcoin anchor tx. */ /* Start creation of the bitcoin anchor tx. */
void bitcoin_create_anchor(struct peer *peer, enum state_input done); void bitcoin_create_anchor(struct peer *peer, enum state_input done);
/* Get the bitcoin anchor tx. */
const struct bitcoin_tx *bitcoin_anchor(struct peer *peer);
/* We didn't end up broadcasting the anchor: release the utxos. /* We didn't end up broadcasting the anchor: release the utxos.
* If done != INPUT_NONE, remove existing create_anchor too. */ * If done != INPUT_NONE, remove existing create_anchor too. */
void bitcoin_release_anchor(struct peer *peer, enum state_input done); void bitcoin_release_anchor(struct peer *peer, enum state_input done);
/* Get the bitcoin anchor tx. */
const struct bitcoin_tx *bitcoin_anchor(struct peer *peer);
/* Create a bitcoin close tx. */
const struct bitcoin_tx *bitcoin_close(struct peer *peer);
/* Create a bitcoin spend tx (to spend our commit's outputs) */
const struct bitcoin_tx *bitcoin_spend_ours(struct peer *peer);
/* Create our commit tx */
const struct bitcoin_tx *bitcoin_commit(struct peer *peer);
#endif /* LIGHTNING_STATE_H */ #endif /* LIGHTNING_STATE_H */