mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 10:39:49 +01:00
7401b26824
Before: Ten builds, laptop -j5, no ccache: ``` real 0m36.686000-38.956000(38.608+/-0.65)s user 2m32.864000-42.253000(40.7545+/-2.7)s sys 0m16.618000-18.316000(17.8531+/-0.48)s ``` Ten builds, laptop -j5, ccache (warm): ``` real 0m8.212000-8.577000(8.39989+/-0.13)s user 0m12.731000-13.212000(12.9751+/-0.17)s sys 0m3.697000-3.902000(3.83722+/-0.064)s ``` After: Ten builds, laptop -j5, no ccache: 8% faster ``` real 0m33.802000-35.773000(35.468+/-0.54)s user 2m19.073000-27.754000(26.2542+/-2.3)s sys 0m15.784000-17.173000(16.7165+/-0.37)s ``` Ten builds, laptop -j5, ccache (warm): 1% faster ``` real 0m8.200000-8.485000(8.30138+/-0.097)s user 0m12.485000-13.100000(12.7344+/-0.19)s sys 0m3.702000-3.889000(3.78787+/-0.056)s ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
141 lines
3.8 KiB
C
141 lines
3.8 KiB
C
#include <ccan/array_size/array_size.h>
|
|
#include <common/htlc.h>
|
|
#include "htlc_state_names_gen.h"
|
|
#include <common/htlc_state.h>
|
|
|
|
const char *htlc_state_name(enum htlc_state s)
|
|
{
|
|
size_t i;
|
|
|
|
for (i = 0; enum_htlc_state_names[i].name; i++)
|
|
if (enum_htlc_state_names[i].v == s)
|
|
return enum_htlc_state_names[i].name;
|
|
return "unknown";
|
|
}
|
|
|
|
/* This is the flags for each state. */
|
|
static const int per_state_bits[] = {
|
|
[SENT_ADD_HTLC] = HTLC_ADDING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_PENDING,
|
|
|
|
[SENT_ADD_COMMIT] = HTLC_ADDING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_ADD_REVOCATION] = HTLC_ADDING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_PENDING
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_ADD_ACK_COMMIT] = HTLC_ADDING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[SENT_ADD_ACK_REVOCATION] = HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_REMOVE_HTLC] = HTLC_REMOVING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_LOCAL_F_PENDING + HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_REMOVE_COMMIT] = HTLC_REMOVING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[SENT_REMOVE_REVOCATION] = HTLC_REMOVING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_REMOTE_F_PENDING
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[SENT_REMOVE_ACK_COMMIT] = HTLC_REMOVING + HTLC_LOCAL_F_OWNER
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_REMOVE_ACK_REVOCATION] = HTLC_LOCAL_F_OWNER
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_ADD_HTLC] = HTLC_ADDING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_PENDING,
|
|
|
|
[RCVD_ADD_COMMIT] = HTLC_ADDING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED,
|
|
|
|
[SENT_ADD_REVOCATION] = HTLC_ADDING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_REMOTE_F_PENDING
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED,
|
|
|
|
[SENT_ADD_ACK_COMMIT] = HTLC_ADDING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_ADD_ACK_REVOCATION] = HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[SENT_REMOVE_HTLC] = HTLC_REMOVING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_REMOTE_F_PENDING
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_REMOTE_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[SENT_REMOVE_COMMIT] = HTLC_REMOVING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_REMOVE_REVOCATION] = HTLC_REMOVING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_LOCAL_F_COMMITTED
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_PENDING
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[RCVD_REMOVE_ACK_COMMIT] = HTLC_REMOVING + HTLC_REMOTE_F_OWNER
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED,
|
|
|
|
[SENT_REMOVE_ACK_REVOCATION] = HTLC_REMOTE_F_OWNER
|
|
+ HTLC_REMOTE_F_REVOKED
|
|
+ HTLC_LOCAL_F_REVOKED
|
|
+ HTLC_LOCAL_F_WAS_COMMITTED
|
|
+ HTLC_REMOTE_F_WAS_COMMITTED
|
|
};
|
|
|
|
int htlc_state_flags(enum htlc_state state)
|
|
{
|
|
assert(state < ARRAY_SIZE(per_state_bits));
|
|
assert(per_state_bits[state]);
|
|
return per_state_bits[state];
|
|
}
|
|
|