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

Commits on Aug 3, 2014

  1. Simple script to update ccan/ dir.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 3, 2014
    Copy the full SHA
    22a58fb View commit details

Commits on Aug 4, 2014

  1. sync: fix get_children.

    We were always asking about the first child, which breaks when there's more
    than one!
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 4, 2014
    Copy the full SHA
    5a0f53d View commit details
  2. peer_cache: rehash if peer offers different port.

    Which it will, if it connects to us.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 4, 2014
    Copy the full SHA
    e490aa2 View commit details
  3. netaddr: get socket address correctly.

    Was fixed in 2751461, then reverted
    in 87e32c8.  Oops.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 4, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    446c372 View commit details
  4. Fix coredump when we're sent a block with an unknown prev.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Aug 4, 2014
    Copy the full SHA
    83f94ae View commit details
Showing with 56 additions and 7 deletions.
  1. +4 −1 netaddr.c
  2. +10 −1 peer.c
  3. +3 −1 recv_block.c
  4. +17 −4 sync.c
  5. +22 −0 tools/update-ccan.sh
5 changes: 4 additions & 1 deletion netaddr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "netaddr.h"
#include "protocol_net.h"
#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
@@ -110,7 +111,7 @@ bool get_fd_addr(int fd, struct protocol_net_address *addr)
struct sockaddr_in in;
struct sockaddr_in6 in6;
} u;
socklen_t len = sizeof(len);
socklen_t len = sizeof(u);

if (getsockname(fd, &u.sa, &len) != 0)
return false;
@@ -122,9 +123,11 @@ bool get_fd_addr(int fd, struct protocol_net_address *addr)
addr->unused = cpu_to_le16(0);
memset(&addr->uuid, 0, sizeof(addr->uuid));
if (u.sa.sa_family == AF_INET) {
assert(len == sizeof(u.in));
ipv4_netaddr(addr, &u.in);
return true;
} else if (u.sa.sa_family == AF_INET6) {
assert(len == sizeof(u.in6));
ipv6_netaddr(addr, &u.in6);
return true;
}
11 changes: 10 additions & 1 deletion peer.c
Original file line number Diff line number Diff line change
@@ -1620,7 +1620,16 @@ static struct io_plan welcome_received(struct io_conn *conn, struct peer *peer)
}

/* Replace port we see with port they want us to connect to. */
peer->you.port = peer->welcome->listen_port;
if (peer->welcome->listen_port != peer->you.port) {
struct protocol_net_address to_addr;
log_debug(peer->log, "Peer wants us to connect to port %u",
le16_to_cpu(peer->welcome->listen_port));
/* Don't remember this one, we can't connect there. */
peer_cache_del(state, &peer->you, true);
to_addr = peer->you;
to_addr.port = peer->welcome->listen_port;
peer_cache_add(state, &to_addr);
}

/* Create/update time for this peer. */
peer_cache_refresh(state, &peer->you);
4 changes: 3 additions & 1 deletion recv_block.c
Original file line number Diff line number Diff line change
@@ -108,7 +108,6 @@ recv_block(struct state *state, struct log *log, struct peer *peer,
todo_done_get_block(peer, &sha, true);
} else
todo_done_get_block(peer, &sha, false);
return PROTOCOL_ECODE_NONE;
}
return e;
}
@@ -392,6 +391,9 @@ enum protocol_ecode recv_block_from_peer(struct peer *peer,
le32_to_cpu(b->hdr->depth));
log_add_struct(peer->log, struct protocol_double_sha, &b->sha);
}
/* If we didn't know prev, this block is still OK so don't hang up. */
if (e == PROTOCOL_ECODE_PRIV_UNKNOWN_PREV)
return PROTOCOL_ECODE_NONE;
return e;
}

21 changes: 17 additions & 4 deletions sync.c
Original file line number Diff line number Diff line change
@@ -203,17 +203,30 @@ enum protocol_ecode recv_children(struct peer *peer,
if (len % sizeof(struct protocol_net_syncblock))
return PROTOCOL_ECODE_INVALID_LEN;

log_debug(peer->log, "Gave us %u children for ", num);
log_add_struct(peer->log, struct protocol_double_sha, &parent->sha);

s = (void *)(pkt + 1);
for (i = 0; i < num; i++) {
const struct block *b = block_find_any(peer->state, &s->block);
const struct block *b;

b = block_find_any(peer->state, &s[i].block);
if (!b) {
/* We'd better find out about this one... */
todo_add_get_block(peer->state, &s->block);
log_debug(peer->log, "Asking about unknown block ");
log_add_struct(peer->log, struct protocol_double_sha,
&s[i].block);
todo_add_get_block(peer->state, &s[i].block);
} else {
/* If they have more children than us, ask deeper. */
if (num_children(b, NULL, 0)
< le32_to_cpu(s[i].children))
todo_add_get_children(peer->state, &b->sha);
< le32_to_cpu(s[i].children)) {
log_debug(peer->log, "Getting more kids for ");
log_add_struct(peer->log, struct protocol_double_sha,
&s[i].block);

todo_add_get_children(peer->state, &s[i].block);
}
}
}

22 changes: 22 additions & 0 deletions tools/update-ccan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/sh

set -e

CCANDIR=${1:-../ccan}
NEW_VERSION=$(git --git-dir=$CCANDIR/.git describe --always)
OLD_VERSION=$(grep '^CCAN version: ' ccan/README | cut -d: -f2)

# Make sure we have a clean tree.
if git status --porcelain | grep -v '^\?\?'; then
echo "Dirty tree" >&2
exit 1
fi

(cd $CCANDIR && git diff $OLD_VERSION $NEW_VERSION ccan/ licenses/ tools/configurator) > ccan/diff
(cd ccan && patch -p1 < diff)
rm ccan/diff
grep -v '^CCAN version: ' ccan/README > ccan/README.new
echo "CCAN version: $NEW_VERSION" >> ccan/README.new
mv ccan/README.new ccan/README

echo "Updated to $NEW_VERSION"