Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rustyrussell/pettycoin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 84e6b5f57560
Choose a base ref
...
head repository: rustyrussell/pettycoin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: de2e9c8945f2
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 30, 2014

  1. Clean up peer logging.

    The peer-provided address got appended to the end of each line:
    
     +0.836160958 DEBUG: seed server supplied 168 bytes of peers2600:3c00::f03c:91ff:fedf:87f4:8323
     +0.836183002 DEBUG: peer_cache adding repeat for 2600:3c00::f03c:91ff:fedf:87f4:8323::ffff:66.228.55.133:8323
     +0.836197505 DEBUG: peer_cache adding repeat for ::ffff:66.228.55.133:8323::ffff:128.199.137.156:8323
     +0.836209405 DEBUG: peer_cache adding repeat for ::ffff:128.199.137.156:83232400:6180:0:d0::bb:3001:8323
     +0.836221552 DEBUG: peer_cache adding repeat for 2400:6180:0:d0::bb:3001:8323
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 30, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    89c0dc2 View commit details
  2. Fix up insufficient peers case.

    Reported-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 30, 2014
    Copy the full SHA
    f02826c View commit details
  3. Cleaner logging, and less spam at --log-level=info.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 30, 2014
    Copy the full SHA
    81dc3fe View commit details
  4. Make "info" the default log level.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 30, 2014
    Copy the full SHA
    de2e9c8 View commit details
Showing with 26 additions and 11 deletions.
  1. +21 −10 peer.c
  2. +4 −0 pending.c
  3. +1 −1 state.c
31 changes: 21 additions & 10 deletions peer.c
Original file line number Diff line number Diff line change
@@ -55,7 +55,9 @@ struct peer_lookup {
struct protocol_pkt_peers *pkt;
};

static bool digest_peer_addrs(struct state *state, const void *data, u32 len)
static bool digest_peer_addrs(struct state *state,
struct log *log,
const void *data, u32 len)
{
u32 num, i;
const struct protocol_net_address *addr = data;
@@ -65,11 +67,13 @@ static bool digest_peer_addrs(struct state *state, const void *data, u32 len)
return false;

for (i = 0; i < num; i++) {
log_add_struct(state->log,
struct protocol_net_address, &addr[i]);
peer_cache_add(state, &addr[i]);
log_add(log, " ");
log_add_struct(log, struct protocol_net_address, &addr[i]);
}

for (i = 0; i < num; i++)
peer_cache_add(state, &addr[i]);

/* We can now get more from cache. */
fill_peers(state);
return true;
@@ -83,7 +87,7 @@ static struct io_plan digest_peer_pkt(struct io_conn *conn,
le32_to_cpu(lookup->pkt->len));

/* Addresses are after header. */
digest_peer_addrs(lookup->state, lookup->pkt + 1,
digest_peer_addrs(lookup->state, lookup->state->log, lookup->pkt + 1,
le32_to_cpu(lookup->pkt->len) - sizeof(*lookup->pkt));
return io_close();
}
@@ -117,14 +121,21 @@ static void seed_peers(struct state *state)
return;
}

/* This can happen in the early, sparse network. */
if (state->peer_seed_count++ > 2) {
if (state->num_peers != 0) {
log_debug(state->log,
"Can't find many peers, settling with %zu",
state->num_peers);
return;
}

if (state->nopeers_ok) {
log_unusual(state->log,
"Can't find peers, staying lonely");
return;
}

fatal(state, "Failed to connect to any peers, or peer server");
fatal(state, "Failed to connect to any peers");
}

if (state->developer_test) {
@@ -137,7 +148,8 @@ static void seed_peers(struct state *state)
"seed file supplied %u bytes of peers",
le32_to_cpu(tal_count(data) - 1));

if (!digest_peer_addrs(state, data, tal_count(data) - 1))
if (!digest_peer_addrs(state, state->log,
data, tal_count(data) - 1))
errx(1, "Invalid contents of addresses file");
tal_free(data);
return;
@@ -200,7 +212,6 @@ void fill_peers(struct state *state)


if (!a) {
log_debug(state->log, "Seeding peer cache");
seed_peers(state);
break;
}
@@ -522,7 +533,7 @@ recv_pkt_peers(struct peer *peer, const struct protocol_pkt_peers *pkt)

log_debug(peer->log, "Peer supplied %u peer bytes", len);

if (!digest_peer_addrs(peer->state, pkt + 1, len))
if (!digest_peer_addrs(peer->state, peer->log, pkt + 1, len))
return PROTOCOL_ECODE_INVALID_LEN;

return PROTOCOL_ECODE_NONE;
4 changes: 4 additions & 0 deletions pending.c
Original file line number Diff line number Diff line change
@@ -167,6 +167,10 @@ void recheck_pending_txs(struct state *state)
unknown = state->pending->num_unknown;
known = num_pending_known(state);

/* Avoid logging if nothing pending. */
if (unknown == 0 && known == 0)
return;

txs = tal_arr(state, const union protocol_tx *, unknown + known);

log_info(state->log, "Rechecking pending (%u known, %u unknown)",
2 changes: 1 addition & 1 deletion state.c
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ struct state *new_state(bool test_net)
s->uuid.bytes[i] = isaac64_next_uint(isaac64, 256);
bitmap_zero(s->peer_map, MAX_PEERS);
s->peer_seed_count = 0;
s->log_level = LOG_BROKEN;
s->log_level = LOG_INFORM;
s->log = new_log(s, NULL, "", s->log_level, STATE_LOG_MAX);
s->generator = "pettycoin-generate";
s->reward_addr = NULL;