cstring *ser_msg_version(const struct msg_version *mv) { cstring *s = cstr_new_sz(256); ser_u32(s, mv->nVersion); ser_u64(s, mv->nServices); ser_s64(s, mv->nTime); ser_bp_addr(s, MIN_PROTO_VERSION, &mv->addrTo); ser_bp_addr(s, MIN_PROTO_VERSION, &mv->addrFrom); ser_u64(s, mv->nonce); ser_str(s, mv->strSubVer, sizeof(mv->strSubVer)); ser_u32(s, mv->nStartingHeight); return s; }
void ser_peer(cstring *s, unsigned int protover, const struct peer *peer) { ser_bp_addr(s, protover, &peer->addr); ser_s64(s, peer->last_ok); ser_u32(s, peer->n_ok); ser_s64(s, peer->last_fail); ser_u32(s, peer->n_fail); }
cstring *ser_msg_addr(unsigned int protover, const struct msg_addr *ma) { cstring *s = cstr_new(NULL); if (!ma || !ma->addrs || !ma->addrs->len) { ser_varlen(s, 0); return s; } ser_varlen(s, ma->addrs->len); unsigned int i; for (i = 0; i < ma->addrs->len; i++) { struct bp_address *addr; addr = parr_idx(ma->addrs, i); ser_bp_addr(s, protover, addr); } return s; }