diff --git a/generated/include/mmx/PlotHeader.hxx b/generated/include/mmx/PlotHeader.hxx new file mode 100644 index 000000000..b9f7ad628 --- /dev/null +++ b/generated/include/mmx/PlotHeader.hxx @@ -0,0 +1,91 @@ + +// AUTO GENERATED by vnxcppcodegen + +#ifndef INCLUDE_mmx_PlotHeader_HXX_ +#define INCLUDE_mmx_PlotHeader_HXX_ + +#include +#include +#include +#include +#include + + +namespace mmx { + +class MMX_EXPORT PlotHeader : public ::vnx::Value { +public: + + int32_t version = 0; + int32_t ksize = 0; + int32_t xbits = 0; + ::mmx::hash_t seed; + ::mmx::pubkey_t farmer_key; + vnx::optional<::mmx::addr_t> contract; + std::vector table_pointers; + + typedef ::vnx::Value Super; + + static const vnx::Hash64 VNX_TYPE_HASH; + static const vnx::Hash64 VNX_CODE_HASH; + + static constexpr uint64_t VNX_TYPE_ID = 0x299c5790983c47b6ull; + + PlotHeader() {} + + vnx::Hash64 get_type_hash() const override; + std::string get_type_name() const override; + const vnx::TypeCode* get_type_code() const override; + + static std::shared_ptr create(); + std::shared_ptr clone() const override; + + void read(vnx::TypeInput& _in, const vnx::TypeCode* _type_code, const uint16_t* _code) override; + void write(vnx::TypeOutput& _out, const vnx::TypeCode* _type_code, const uint16_t* _code) const override; + + void read(std::istream& _in) override; + void write(std::ostream& _out) const override; + + template + void accept_generic(T& _visitor) const; + void accept(vnx::Visitor& _visitor) const override; + + vnx::Object to_object() const override; + void from_object(const vnx::Object& object) override; + + vnx::Variant get_field(const std::string& name) const override; + void set_field(const std::string& name, const vnx::Variant& value) override; + + friend std::ostream& operator<<(std::ostream& _out, const PlotHeader& _value); + friend std::istream& operator>>(std::istream& _in, PlotHeader& _value); + + static const vnx::TypeCode* static_get_type_code(); + static std::shared_ptr static_create_type_code(); + +protected: + std::shared_ptr vnx_call_switch(std::shared_ptr _method) override; + +}; + +template +void PlotHeader::accept_generic(T& _visitor) const { + _visitor.template type_begin(7); + _visitor.type_field("version", 0); _visitor.accept(version); + _visitor.type_field("ksize", 1); _visitor.accept(ksize); + _visitor.type_field("xbits", 2); _visitor.accept(xbits); + _visitor.type_field("seed", 3); _visitor.accept(seed); + _visitor.type_field("farmer_key", 4); _visitor.accept(farmer_key); + _visitor.type_field("contract", 5); _visitor.accept(contract); + _visitor.type_field("table_pointers", 6); _visitor.accept(table_pointers); + _visitor.template type_end(7); +} + + +} // namespace mmx + + +namespace vnx { + +} // vnx + +#endif // INCLUDE_mmx_PlotHeader_HXX_ diff --git a/generated/include/mmx/package.hxx b/generated/include/mmx/package.hxx index f2ad49583..b79aaa7ef 100644 --- a/generated/include/mmx/package.hxx +++ b/generated/include/mmx/package.hxx @@ -245,6 +245,7 @@ class Operation_calc_hash_return; class Operation_is_valid; class Operation_is_valid_return; class PeerInfo; +class PlotHeader; class ProofOfSpace; class ProofOfSpace_calc_hash; class ProofOfSpace_calc_hash_return; @@ -755,6 +756,7 @@ MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_Operation_calc MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_Operation_is_valid; ///< \private MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_Operation_is_valid_return; ///< \private MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_PeerInfo; ///< \private +MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_PlotHeader; ///< \private MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_ProofOfSpace; ///< \private MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_ProofOfSpace_calc_hash; ///< \private MMX_EXPORT extern const vnx::TypeCode* const vnx_native_type_code_ProofOfSpace_calc_hash_return; ///< \private @@ -1261,6 +1263,7 @@ void read(TypeInput& in, ::mmx::Operation_calc_hash_return& value, const TypeCod void read(TypeInput& in, ::mmx::Operation_is_valid& value, const TypeCode* type_code, const uint16_t* code); ///< \private void read(TypeInput& in, ::mmx::Operation_is_valid_return& value, const TypeCode* type_code, const uint16_t* code); ///< \private void read(TypeInput& in, ::mmx::PeerInfo& value, const TypeCode* type_code, const uint16_t* code); ///< \private +void read(TypeInput& in, ::mmx::PlotHeader& value, const TypeCode* type_code, const uint16_t* code); ///< \private void read(TypeInput& in, ::mmx::ProofOfSpace& value, const TypeCode* type_code, const uint16_t* code); ///< \private void read(TypeInput& in, ::mmx::ProofOfSpace_calc_hash& value, const TypeCode* type_code, const uint16_t* code); ///< \private void read(TypeInput& in, ::mmx::ProofOfSpace_calc_hash_return& value, const TypeCode* type_code, const uint16_t* code); ///< \private @@ -1771,6 +1774,7 @@ void write(TypeOutput& out, const ::mmx::Operation_calc_hash_return& value, cons void write(TypeOutput& out, const ::mmx::Operation_is_valid& value, const TypeCode* type_code, const uint16_t* code); ///< \private void write(TypeOutput& out, const ::mmx::Operation_is_valid_return& value, const TypeCode* type_code, const uint16_t* code); ///< \private void write(TypeOutput& out, const ::mmx::PeerInfo& value, const TypeCode* type_code, const uint16_t* code); ///< \private +void write(TypeOutput& out, const ::mmx::PlotHeader& value, const TypeCode* type_code, const uint16_t* code); ///< \private void write(TypeOutput& out, const ::mmx::ProofOfSpace& value, const TypeCode* type_code, const uint16_t* code); ///< \private void write(TypeOutput& out, const ::mmx::ProofOfSpace_calc_hash& value, const TypeCode* type_code, const uint16_t* code); ///< \private void write(TypeOutput& out, const ::mmx::ProofOfSpace_calc_hash_return& value, const TypeCode* type_code, const uint16_t* code); ///< \private @@ -2281,6 +2285,7 @@ void read(std::istream& in, ::mmx::Operation_calc_hash_return& value); ///< \pri void read(std::istream& in, ::mmx::Operation_is_valid& value); ///< \private void read(std::istream& in, ::mmx::Operation_is_valid_return& value); ///< \private void read(std::istream& in, ::mmx::PeerInfo& value); ///< \private +void read(std::istream& in, ::mmx::PlotHeader& value); ///< \private void read(std::istream& in, ::mmx::ProofOfSpace& value); ///< \private void read(std::istream& in, ::mmx::ProofOfSpace_calc_hash& value); ///< \private void read(std::istream& in, ::mmx::ProofOfSpace_calc_hash_return& value); ///< \private @@ -2791,6 +2796,7 @@ void write(std::ostream& out, const ::mmx::Operation_calc_hash_return& value); / void write(std::ostream& out, const ::mmx::Operation_is_valid& value); ///< \private void write(std::ostream& out, const ::mmx::Operation_is_valid_return& value); ///< \private void write(std::ostream& out, const ::mmx::PeerInfo& value); ///< \private +void write(std::ostream& out, const ::mmx::PlotHeader& value); ///< \private void write(std::ostream& out, const ::mmx::ProofOfSpace& value); ///< \private void write(std::ostream& out, const ::mmx::ProofOfSpace_calc_hash& value); ///< \private void write(std::ostream& out, const ::mmx::ProofOfSpace_calc_hash_return& value); ///< \private @@ -3301,6 +3307,7 @@ void accept(Visitor& visitor, const ::mmx::Operation_calc_hash_return& value); / void accept(Visitor& visitor, const ::mmx::Operation_is_valid& value); ///< \private void accept(Visitor& visitor, const ::mmx::Operation_is_valid_return& value); ///< \private void accept(Visitor& visitor, const ::mmx::PeerInfo& value); ///< \private +void accept(Visitor& visitor, const ::mmx::PlotHeader& value); ///< \private void accept(Visitor& visitor, const ::mmx::ProofOfSpace& value); ///< \private void accept(Visitor& visitor, const ::mmx::ProofOfSpace_calc_hash& value); ///< \private void accept(Visitor& visitor, const ::mmx::ProofOfSpace_calc_hash_return& value); ///< \private @@ -8708,6 +8715,29 @@ struct type<::mmx::PeerInfo> { void create_dynamic_code(std::vector& code, const ::mmx::PeerInfo& value, bool special = false); }; +/// \private +template<> +struct type<::mmx::PlotHeader> { + void read(TypeInput& in, ::mmx::PlotHeader& value, const TypeCode* type_code, const uint16_t* code) { + vnx::read(in, value, type_code, code); + } + void write(TypeOutput& out, const ::mmx::PlotHeader& value, const TypeCode* type_code, const uint16_t* code) { + vnx::write(out, value, type_code, code); + } + void read(std::istream& in, ::mmx::PlotHeader& value) { + vnx::read(in, value); + } + void write(std::ostream& out, const ::mmx::PlotHeader& value) { + vnx::write(out, value); + } + void accept(Visitor& visitor, const ::mmx::PlotHeader& value) { + vnx::accept(visitor, value); + } + const TypeCode* get_type_code(); + void create_dynamic_code(std::vector& code); + void create_dynamic_code(std::vector& code, const ::mmx::PlotHeader& value, bool special = false); +}; + /// \private template<> struct type<::mmx::ProofOfSpace> { diff --git a/generated/src/PlotHeader.cpp b/generated/src/PlotHeader.cpp new file mode 100644 index 000000000..b45dbc4c2 --- /dev/null +++ b/generated/src/PlotHeader.cpp @@ -0,0 +1,331 @@ + +// AUTO GENERATED by vnxcppcodegen + +#include +#include +#include +#include +#include +#include + +#include + + +namespace mmx { + + +const vnx::Hash64 PlotHeader::VNX_TYPE_HASH(0x299c5790983c47b6ull); +const vnx::Hash64 PlotHeader::VNX_CODE_HASH(0xa165f45a567004d8ull); + +vnx::Hash64 PlotHeader::get_type_hash() const { + return VNX_TYPE_HASH; +} + +std::string PlotHeader::get_type_name() const { + return "mmx.PlotHeader"; +} + +const vnx::TypeCode* PlotHeader::get_type_code() const { + return mmx::vnx_native_type_code_PlotHeader; +} + +std::shared_ptr PlotHeader::create() { + return std::make_shared(); +} + +std::shared_ptr PlotHeader::clone() const { + return std::make_shared(*this); +} + +void PlotHeader::read(vnx::TypeInput& _in, const vnx::TypeCode* _type_code, const uint16_t* _code) { + vnx::read(_in, *this, _type_code, _code); +} + +void PlotHeader::write(vnx::TypeOutput& _out, const vnx::TypeCode* _type_code, const uint16_t* _code) const { + vnx::write(_out, *this, _type_code, _code); +} + +void PlotHeader::accept(vnx::Visitor& _visitor) const { + const vnx::TypeCode* _type_code = mmx::vnx_native_type_code_PlotHeader; + _visitor.type_begin(*_type_code); + _visitor.type_field(_type_code->fields[0], 0); vnx::accept(_visitor, version); + _visitor.type_field(_type_code->fields[1], 1); vnx::accept(_visitor, ksize); + _visitor.type_field(_type_code->fields[2], 2); vnx::accept(_visitor, xbits); + _visitor.type_field(_type_code->fields[3], 3); vnx::accept(_visitor, seed); + _visitor.type_field(_type_code->fields[4], 4); vnx::accept(_visitor, farmer_key); + _visitor.type_field(_type_code->fields[5], 5); vnx::accept(_visitor, contract); + _visitor.type_field(_type_code->fields[6], 6); vnx::accept(_visitor, table_pointers); + _visitor.type_end(*_type_code); +} + +void PlotHeader::write(std::ostream& _out) const { + _out << "{\"__type\": \"mmx.PlotHeader\""; + _out << ", \"version\": "; vnx::write(_out, version); + _out << ", \"ksize\": "; vnx::write(_out, ksize); + _out << ", \"xbits\": "; vnx::write(_out, xbits); + _out << ", \"seed\": "; vnx::write(_out, seed); + _out << ", \"farmer_key\": "; vnx::write(_out, farmer_key); + _out << ", \"contract\": "; vnx::write(_out, contract); + _out << ", \"table_pointers\": "; vnx::write(_out, table_pointers); + _out << "}"; +} + +void PlotHeader::read(std::istream& _in) { + if(auto _json = vnx::read_json(_in)) { + from_object(_json->to_object()); + } +} + +vnx::Object PlotHeader::to_object() const { + vnx::Object _object; + _object["__type"] = "mmx.PlotHeader"; + _object["version"] = version; + _object["ksize"] = ksize; + _object["xbits"] = xbits; + _object["seed"] = seed; + _object["farmer_key"] = farmer_key; + _object["contract"] = contract; + _object["table_pointers"] = table_pointers; + return _object; +} + +void PlotHeader::from_object(const vnx::Object& _object) { + for(const auto& _entry : _object.field) { + if(_entry.first == "contract") { + _entry.second.to(contract); + } else if(_entry.first == "farmer_key") { + _entry.second.to(farmer_key); + } else if(_entry.first == "ksize") { + _entry.second.to(ksize); + } else if(_entry.first == "seed") { + _entry.second.to(seed); + } else if(_entry.first == "table_pointers") { + _entry.second.to(table_pointers); + } else if(_entry.first == "version") { + _entry.second.to(version); + } else if(_entry.first == "xbits") { + _entry.second.to(xbits); + } + } +} + +vnx::Variant PlotHeader::get_field(const std::string& _name) const { + if(_name == "version") { + return vnx::Variant(version); + } + if(_name == "ksize") { + return vnx::Variant(ksize); + } + if(_name == "xbits") { + return vnx::Variant(xbits); + } + if(_name == "seed") { + return vnx::Variant(seed); + } + if(_name == "farmer_key") { + return vnx::Variant(farmer_key); + } + if(_name == "contract") { + return vnx::Variant(contract); + } + if(_name == "table_pointers") { + return vnx::Variant(table_pointers); + } + return vnx::Variant(); +} + +void PlotHeader::set_field(const std::string& _name, const vnx::Variant& _value) { + if(_name == "version") { + _value.to(version); + } else if(_name == "ksize") { + _value.to(ksize); + } else if(_name == "xbits") { + _value.to(xbits); + } else if(_name == "seed") { + _value.to(seed); + } else if(_name == "farmer_key") { + _value.to(farmer_key); + } else if(_name == "contract") { + _value.to(contract); + } else if(_name == "table_pointers") { + _value.to(table_pointers); + } +} + +/// \private +std::ostream& operator<<(std::ostream& _out, const PlotHeader& _value) { + _value.write(_out); + return _out; +} + +/// \private +std::istream& operator>>(std::istream& _in, PlotHeader& _value) { + _value.read(_in); + return _in; +} + +const vnx::TypeCode* PlotHeader::static_get_type_code() { + const vnx::TypeCode* type_code = vnx::get_type_code(VNX_TYPE_HASH); + if(!type_code) { + type_code = vnx::register_type_code(static_create_type_code()); + } + return type_code; +} + +std::shared_ptr PlotHeader::static_create_type_code() { + auto type_code = std::make_shared(); + type_code->name = "mmx.PlotHeader"; + type_code->type_hash = vnx::Hash64(0x299c5790983c47b6ull); + type_code->code_hash = vnx::Hash64(0xa165f45a567004d8ull); + type_code->is_native = true; + type_code->is_class = true; + type_code->native_size = sizeof(::mmx::PlotHeader); + type_code->create_value = []() -> std::shared_ptr { return std::make_shared(); }; + type_code->fields.resize(7); + { + auto& field = type_code->fields[0]; + field.data_size = 4; + field.name = "version"; + field.code = {7}; + } + { + auto& field = type_code->fields[1]; + field.data_size = 4; + field.name = "ksize"; + field.code = {7}; + } + { + auto& field = type_code->fields[2]; + field.data_size = 4; + field.name = "xbits"; + field.code = {7}; + } + { + auto& field = type_code->fields[3]; + field.is_extended = true; + field.name = "seed"; + field.code = {11, 32, 1}; + } + { + auto& field = type_code->fields[4]; + field.is_extended = true; + field.name = "farmer_key"; + field.code = {11, 33, 1}; + } + { + auto& field = type_code->fields[5]; + field.is_extended = true; + field.name = "contract"; + field.code = {33, 11, 32, 1}; + } + { + auto& field = type_code->fields[6]; + field.is_extended = true; + field.name = "table_pointers"; + field.code = {12, 4}; + } + type_code->build(); + return type_code; +} + +std::shared_ptr PlotHeader::vnx_call_switch(std::shared_ptr _method) { + switch(_method->get_type_hash()) { + } + return nullptr; +} + + +} // namespace mmx + + +namespace vnx { + +void read(TypeInput& in, ::mmx::PlotHeader& value, const TypeCode* type_code, const uint16_t* code) { + if(code) { + switch(code[0]) { + case CODE_OBJECT: + case CODE_ALT_OBJECT: { + Object tmp; + vnx::read(in, tmp, type_code, code); + value.from_object(tmp); + return; + } + case CODE_DYNAMIC: + case CODE_ALT_DYNAMIC: + vnx::read_dynamic(in, value); + return; + } + } + if(!type_code) { + vnx::skip(in, type_code, code); + return; + } + if(code) { + switch(code[0]) { + case CODE_STRUCT: type_code = type_code->depends[code[1]]; break; + case CODE_ALT_STRUCT: type_code = type_code->depends[vnx::flip_bytes(code[1])]; break; + default: { + vnx::skip(in, type_code, code); + return; + } + } + } + const char* const _buf = in.read(type_code->total_field_size); + if(type_code->is_matched) { + if(const auto* const _field = type_code->field_map[0]) { + vnx::read_value(_buf + _field->offset, value.version, _field->code.data()); + } + if(const auto* const _field = type_code->field_map[1]) { + vnx::read_value(_buf + _field->offset, value.ksize, _field->code.data()); + } + if(const auto* const _field = type_code->field_map[2]) { + vnx::read_value(_buf + _field->offset, value.xbits, _field->code.data()); + } + } + for(const auto* _field : type_code->ext_fields) { + switch(_field->native_index) { + case 3: vnx::read(in, value.seed, type_code, _field->code.data()); break; + case 4: vnx::read(in, value.farmer_key, type_code, _field->code.data()); break; + case 5: vnx::read(in, value.contract, type_code, _field->code.data()); break; + case 6: vnx::read(in, value.table_pointers, type_code, _field->code.data()); break; + default: vnx::skip(in, type_code, _field->code.data()); + } + } +} + +void write(TypeOutput& out, const ::mmx::PlotHeader& value, const TypeCode* type_code, const uint16_t* code) { + if(code && code[0] == CODE_OBJECT) { + vnx::write(out, value.to_object(), nullptr, code); + return; + } + if(!type_code || (code && code[0] == CODE_ANY)) { + type_code = mmx::vnx_native_type_code_PlotHeader; + out.write_type_code(type_code); + vnx::write_class_header<::mmx::PlotHeader>(out); + } + else if(code && code[0] == CODE_STRUCT) { + type_code = type_code->depends[code[1]]; + } + char* const _buf = out.write(12); + vnx::write_value(_buf + 0, value.version); + vnx::write_value(_buf + 4, value.ksize); + vnx::write_value(_buf + 8, value.xbits); + vnx::write(out, value.seed, type_code, type_code->fields[3].code.data()); + vnx::write(out, value.farmer_key, type_code, type_code->fields[4].code.data()); + vnx::write(out, value.contract, type_code, type_code->fields[5].code.data()); + vnx::write(out, value.table_pointers, type_code, type_code->fields[6].code.data()); +} + +void read(std::istream& in, ::mmx::PlotHeader& value) { + value.read(in); +} + +void write(std::ostream& out, const ::mmx::PlotHeader& value) { + value.write(out); +} + +void accept(Visitor& visitor, const ::mmx::PlotHeader& value) { + value.accept(visitor); +} + +} // vnx diff --git a/generated/src/package.cpp b/generated/src/package.cpp index 0d7c7956e..f199ea919 100644 --- a/generated/src/package.cpp +++ b/generated/src/package.cpp @@ -224,6 +224,7 @@ #include #include #include +#include #include #include #include @@ -3158,6 +3159,18 @@ void type<::mmx::PeerInfo>::create_dynamic_code(std::vector& code, con code.push_back(CODE_OBJECT); } +const TypeCode* type<::mmx::PlotHeader>::get_type_code() { + return mmx::vnx_native_type_code_PlotHeader; +} + +void type<::mmx::PlotHeader>::create_dynamic_code(std::vector& code) { + create_dynamic_code(code, ::mmx::PlotHeader()); +} + +void type<::mmx::PlotHeader>::create_dynamic_code(std::vector& code, const ::mmx::PlotHeader& value, bool special) { + code.push_back(CODE_OBJECT); +} + const TypeCode* type<::mmx::ProofOfSpace>::get_type_code() { return mmx::vnx_native_type_code_ProofOfSpace; } @@ -6793,6 +6806,7 @@ static void register_all_types() { vnx::register_type_code(::mmx::Operation_is_valid::static_create_type_code()); vnx::register_type_code(::mmx::Operation_is_valid_return::static_create_type_code()); vnx::register_type_code(::mmx::PeerInfo::static_create_type_code()); + vnx::register_type_code(::mmx::PlotHeader::static_create_type_code()); vnx::register_type_code(::mmx::ProofOfSpace::static_create_type_code()); vnx::register_type_code(::mmx::ProofOfSpace_calc_hash::static_create_type_code()); vnx::register_type_code(::mmx::ProofOfSpace_calc_hash_return::static_create_type_code()); @@ -7301,6 +7315,7 @@ const vnx::TypeCode* const vnx_native_type_code_Operation_calc_hash_return = vnx const vnx::TypeCode* const vnx_native_type_code_Operation_is_valid = vnx::get_type_code(vnx::Hash64(0x3b2ec6e0a968cf51ull)); const vnx::TypeCode* const vnx_native_type_code_Operation_is_valid_return = vnx::get_type_code(vnx::Hash64(0x1324d5d2902c32f9ull)); const vnx::TypeCode* const vnx_native_type_code_PeerInfo = vnx::get_type_code(vnx::Hash64(0xf7a37f624c94a121ull)); +const vnx::TypeCode* const vnx_native_type_code_PlotHeader = vnx::get_type_code(vnx::Hash64(0x299c5790983c47b6ull)); const vnx::TypeCode* const vnx_native_type_code_ProofOfSpace = vnx::get_type_code(vnx::Hash64(0x9269760ad5fd0058ull)); const vnx::TypeCode* const vnx_native_type_code_ProofOfSpace_calc_hash = vnx::get_type_code(vnx::Hash64(0x4056d25a9096f144ull)); const vnx::TypeCode* const vnx_native_type_code_ProofOfSpace_calc_hash_return = vnx::get_type_code(vnx::Hash64(0x83ae337b27aae652ull));