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: 297d09d31d7f
Choose a base ref
...
head repository: rustyrussell/pettycoin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6851d6277224
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 16, 2014

  1. chain: fix check_chains() (Fixes #33)

    Bugs cause segv on startup.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 16, 2014
    Copy the full SHA
    f99b1ab View commit details
  2. block_info: remove unused prevs field.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 16, 2014
    Copy the full SHA
    727ec75 View commit details
  3. recv_block: ask for block contents on reinject.

    Now we query blocks out of order, we often will get a block through
    reinjection (once we finally get its prev) rather than directly from
    the packet path.  Assume that if this happens, we are syncing, and thus
    want to ask about contents and children.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 16, 2014
    Copy the full SHA
    6851d62 View commit details
Showing with 8 additions and 9 deletions.
  1. +0 −2 block_info.h
  2. +2 −2 chain.c
  3. +6 −5 recv_block.c
2 changes: 0 additions & 2 deletions block_info.h
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@
struct block_info {
/* The pettycoin part: */
const struct protocol_block_header *hdr;
/* There are num_prevs(hdr) protocoL_block_id: */
const struct protocol_block_id *prevs;
/* There are num_shards(hdr) u8: */
const u8 *num_txs;
/* There are num_shards(hdr) protocol_double_sha: */
4 changes: 2 additions & 2 deletions chain.c
Original file line number Diff line number Diff line change
@@ -138,9 +138,9 @@ void check_chains(struct state *state, bool all)
else {
struct protocol_block_id prevs
[PROTOCOL_NUM_PREV_IDS];
make_prev_blocks(b->prev, prevs);
make_prev_blocks(i->prev, prevs);
assert(memcmp(block_prev(&i->bi, 0), prevs,
sizeof(prevs) == 0));
sizeof(prevs)) == 0);
if (i->prev->complaint)
assert(i->complaint);
}
11 changes: 6 additions & 5 deletions recv_block.c
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ static void ask_block_contents(struct state *state, const struct block *b)
/* peer is NULL if from generator, re-trying detached block or jsonrpc. */
static enum protocol_ecode
recv_block(struct state *state, struct log *log, struct peer *peer,
const tal_t *pkt_ctx, const struct block_info *bi,
const tal_t *pkt_ctx, const struct block_info *bi, bool need_contents,
struct block **block)
{
struct block *b, *prev;
@@ -184,7 +184,7 @@ recv_block(struct state *state, struct log *log, struct peer *peer,
bad_shard);
} else {
/* If we're syncing, ask about children, contents */
if (peer && peer->we_are_syncing) {
if (need_contents) {
/* FIXME: Don't do these if below horizon */
todo_add_get_children(state, &b->sha);
get_block_contents(state, b);
@@ -229,7 +229,7 @@ recv_block_pkt(struct state *state, struct log *log, struct peer *peer,
return e;
}

return recv_block(state, log, peer, pkt, &bi, block);
return recv_block(state, log, peer, pkt, &bi, peer->we_are_syncing, block);
}

static struct txptr_with_ref
@@ -525,7 +525,8 @@ void recv_block_reinject(struct state *state,
{
struct block *b;

recv_block(state, state->log, NULL, pkt_ctx, bi, &b);
/* A reinject implies we are catching up: explicitly ask for contents. */
recv_block(state, state->log, NULL, pkt_ctx, bi, true, &b);
}

static char *json_submitblock(struct json_connection *jcon,
@@ -553,7 +554,7 @@ static char *json_submitblock(struct json_connection *jcon,
if (e != PROTOCOL_ECODE_NONE)
return (char *)ecode_name(e);

e = recv_block(jcon->state, jcon->log, NULL, data, &bi, &block);
e = recv_block(jcon->state, jcon->log, NULL, data, &bi, false, &block);
if (e != PROTOCOL_ECODE_NONE)
return (char *)ecode_name(e);