jsonrpc: Added nested messages for the getroute reply

The `route_hop` struct introduced in the previous refactoring is
reused when returning the reply to a `getroute` request. Since these
are nested messages I added the serialization and deserialization
methods.
This commit is contained in:
Christian Decker 2017-03-15 13:36:35 +01:00 committed by Rusty Russell
parent 73e65cac4d
commit 2d198e22d0
2 changed files with 18 additions and 0 deletions

View File

@ -25,3 +25,17 @@ void towire_gossip_getnodes_entry(u8 **pptr, const struct gossip_getnodes_entry
}
towire_u16(pptr, entry->port);
}
void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry)
{
fromwire_pubkey(pptr, max, &entry->nodeid);
entry->amount = fromwire_u32(pptr, max);
entry->delay = fromwire_u32(pptr, max);
}
void towire_route_hop(u8 **pptr, const struct route_hop *entry)
{
towire_pubkey(pptr, &entry->nodeid);
towire_u32(pptr, entry->amount);
towire_u32(pptr, entry->delay);
}

View File

@ -2,6 +2,7 @@
#define LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H
#include "config.h"
#include <bitcoin/pubkey.h>
#include <daemon/routing.h>
struct gossip_getnodes_entry {
struct pubkey nodeid;
@ -12,4 +13,7 @@ struct gossip_getnodes_entry {
void fromwire_gossip_getnodes_entry(const tal_t *ctx, const u8 **pptr, size_t *max, struct gossip_getnodes_entry *entry);
void towire_gossip_getnodes_entry(u8 **pptr, const struct gossip_getnodes_entry *entry);
void fromwire_route_hop(const u8 **pprt, size_t *max, struct route_hop *entry);
void towire_route_hop(u8 **pprt, const struct route_hop *entry);
#endif /* LIGHTNING_LIGHTGNINGD_GOSSIP_MSG_H */