bool alert_payload::from_data(reader& source) { reset(); version = source.read_4_bytes_little_endian(); relay_until = source.read_8_bytes_little_endian(); expiration = source.read_8_bytes_little_endian(); id = source.read_4_bytes_little_endian(); cancel = source.read_4_bytes_little_endian(); uint64_t set_cancel_size = source.read_variable_uint_little_endian(); for (uint64_t i = 0; i < set_cancel_size && source; i++) set_cancel.push_back(source.read_4_bytes_little_endian()); min_version = source.read_4_bytes_little_endian(); max_version = source.read_4_bytes_little_endian(); uint64_t set_sub_version_size = source.read_variable_uint_little_endian(); for (uint64_t i = 0; i < set_sub_version_size && source; i++) set_sub_version.push_back(source.read_string()); priority = source.read_4_bytes_little_endian(); comment = source.read_string(); status_bar = source.read_string(); reserved = source.read_string(); if (!source) reset(); return source; }
bool version::from_data(reader& source) { reset(); value = source.read_4_bytes_little_endian(); services = source.read_8_bytes_little_endian(); timestamp = source.read_8_bytes_little_endian(); auto result = static_cast<bool>(source); if (result) result = address_me.from_data(source, false); if (result && (value >= 106)) { result = address_you.from_data(source, false); nonce = source.read_8_bytes_little_endian(); user_agent = source.read_string(); if (value >= 209) start_height = source.read_4_bytes_little_endian(); // The satoshi client treats 209 as the "initial protocol version" // and disconnects peers below 31800 (for getheaders support). if (value >= 70001) relay = (source.read_byte() != 0); result &= source; } if (!result) reset(); return result; }
bool reject::from_data(reader& source) { bool result = 0; reset(); message = source.read_string(); code = error_code_from_byte(source.read_byte()); reason = source.read_string(); if ((message == chain::block::command) || (message == chain::transaction::command)) { data = source.read_hash(); } result = source; if (!result) reset(); return result; }