nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit 18d3393ab564921a7a0306d31dd3f556397e0196
parent 1378a29c1ba400dd5a4540717b8af9a29d5a2430
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 10 Aug 2023 12:25:37 -0700

profile: remove json from bindings

These will be stored in the contentf of the event anyways

Diffstat:
Mbindings/c/profile_builder.h | 55++++++++++++++++++++++++++-----------------------------
Mbindings/c/profile_reader.h | 23+++++++++++------------
Mbindings/c/profile_verifier.h | 23+++++++++++------------
Mbindings/swift/NdbProfile.swift | 31++++++++++++-------------------
Mschemas/profile.fbs | 3---
5 files changed, 60 insertions(+), 75 deletions(-)

diff --git a/bindings/c/profile_builder.h b/bindings/c/profile_builder.h @@ -20,47 +20,45 @@ static const flatbuffers_voffset_t __NdbProfile_required[] = { 0 }; typedef flatbuffers_ref_t NdbProfile_ref_t; static NdbProfile_ref_t NdbProfile_clone(flatbuffers_builder_t *B, NdbProfile_table_t t); -__flatbuffers_build_table(flatbuffers_, NdbProfile, 12) +__flatbuffers_build_table(flatbuffers_, NdbProfile, 11) #define __NdbProfile_formal_args ,\ flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1, flatbuffers_string_ref_t v2, flatbuffers_string_ref_t v3,\ - flatbuffers_string_ref_t v4, flatbuffers_string_ref_t v5, flatbuffers_string_ref_t v6, flatbuffers_bool_t v7,\ - flatbuffers_string_ref_t v8, flatbuffers_string_ref_t v9, int32_t v10, int32_t v11 + flatbuffers_string_ref_t v4, flatbuffers_string_ref_t v5, flatbuffers_bool_t v6, flatbuffers_string_ref_t v7,\ + flatbuffers_string_ref_t v8, int32_t v9, int32_t v10 #define __NdbProfile_call_args ,\ v0, v1, v2, v3,\ v4, v5, v6, v7,\ - v8, v9, v10, v11 + v8, v9, v10 static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbProfile_formal_args); __flatbuffers_build_table_prolog(flatbuffers_, NdbProfile, NdbProfile_file_identifier, NdbProfile_type_identifier) -__flatbuffers_build_string_field(0, flatbuffers_, NdbProfile_json, NdbProfile) -__flatbuffers_build_string_field(1, flatbuffers_, NdbProfile_name, NdbProfile) -__flatbuffers_build_string_field(2, flatbuffers_, NdbProfile_website, NdbProfile) -__flatbuffers_build_string_field(3, flatbuffers_, NdbProfile_about, NdbProfile) -__flatbuffers_build_string_field(4, flatbuffers_, NdbProfile_lud16, NdbProfile) -__flatbuffers_build_string_field(5, flatbuffers_, NdbProfile_banner, NdbProfile) -__flatbuffers_build_string_field(6, flatbuffers_, NdbProfile_display_name, NdbProfile) -__flatbuffers_build_scalar_field(7, flatbuffers_, NdbProfile_reactions, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(1), NdbProfile) -__flatbuffers_build_string_field(8, flatbuffers_, NdbProfile_picture, NdbProfile) -__flatbuffers_build_string_field(9, flatbuffers_, NdbProfile_nip05, NdbProfile) -__flatbuffers_build_scalar_field(10, flatbuffers_, NdbProfile_damus_donation, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), NdbProfile) -__flatbuffers_build_scalar_field(11, flatbuffers_, NdbProfile_damus_donation_v2, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), NdbProfile) +__flatbuffers_build_string_field(0, flatbuffers_, NdbProfile_name, NdbProfile) +__flatbuffers_build_string_field(1, flatbuffers_, NdbProfile_website, NdbProfile) +__flatbuffers_build_string_field(2, flatbuffers_, NdbProfile_about, NdbProfile) +__flatbuffers_build_string_field(3, flatbuffers_, NdbProfile_lud16, NdbProfile) +__flatbuffers_build_string_field(4, flatbuffers_, NdbProfile_banner, NdbProfile) +__flatbuffers_build_string_field(5, flatbuffers_, NdbProfile_display_name, NdbProfile) +__flatbuffers_build_scalar_field(6, flatbuffers_, NdbProfile_reactions, flatbuffers_bool, flatbuffers_bool_t, 1, 1, UINT8_C(1), NdbProfile) +__flatbuffers_build_string_field(7, flatbuffers_, NdbProfile_picture, NdbProfile) +__flatbuffers_build_string_field(8, flatbuffers_, NdbProfile_nip05, NdbProfile) +__flatbuffers_build_scalar_field(9, flatbuffers_, NdbProfile_damus_donation, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), NdbProfile) +__flatbuffers_build_scalar_field(10, flatbuffers_, NdbProfile_damus_donation_v2, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), NdbProfile) static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbProfile_formal_args) { if (NdbProfile_start(B) - || NdbProfile_json_add(B, v0) - || NdbProfile_name_add(B, v1) - || NdbProfile_website_add(B, v2) - || NdbProfile_about_add(B, v3) - || NdbProfile_lud16_add(B, v4) - || NdbProfile_banner_add(B, v5) - || NdbProfile_display_name_add(B, v6) - || NdbProfile_picture_add(B, v8) - || NdbProfile_nip05_add(B, v9) - || NdbProfile_damus_donation_add(B, v10) - || NdbProfile_damus_donation_v2_add(B, v11) - || NdbProfile_reactions_add(B, v7)) { + || NdbProfile_name_add(B, v0) + || NdbProfile_website_add(B, v1) + || NdbProfile_about_add(B, v2) + || NdbProfile_lud16_add(B, v3) + || NdbProfile_banner_add(B, v4) + || NdbProfile_display_name_add(B, v5) + || NdbProfile_picture_add(B, v7) + || NdbProfile_nip05_add(B, v8) + || NdbProfile_damus_donation_add(B, v9) + || NdbProfile_damus_donation_v2_add(B, v10) + || NdbProfile_reactions_add(B, v6)) { return 0; } return NdbProfile_end(B); @@ -70,7 +68,6 @@ static NdbProfile_ref_t NdbProfile_clone(flatbuffers_builder_t *B, NdbProfile_ta { __flatbuffers_memoize_begin(B, t); if (NdbProfile_start(B) - || NdbProfile_json_pick(B, t) || NdbProfile_name_pick(B, t) || NdbProfile_website_pick(B, t) || NdbProfile_about_pick(B, t) diff --git a/bindings/c/profile_reader.h b/bindings/c/profile_reader.h @@ -46,18 +46,17 @@ static inline NdbProfile_table_t NdbProfile_vec_at(NdbProfile_vec_t vec, size_t __flatbuffers_offset_vec_at(NdbProfile_table_t, vec, i, 0) __flatbuffers_table_as_root(NdbProfile) -__flatbuffers_define_string_field(0, NdbProfile, json, 0) -__flatbuffers_define_string_field(1, NdbProfile, name, 0) -__flatbuffers_define_string_field(2, NdbProfile, website, 0) -__flatbuffers_define_string_field(3, NdbProfile, about, 0) -__flatbuffers_define_string_field(4, NdbProfile, lud16, 0) -__flatbuffers_define_string_field(5, NdbProfile, banner, 0) -__flatbuffers_define_string_field(6, NdbProfile, display_name, 0) -__flatbuffers_define_scalar_field(7, NdbProfile, reactions, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(1)) -__flatbuffers_define_string_field(8, NdbProfile, picture, 0) -__flatbuffers_define_string_field(9, NdbProfile, nip05, 0) -__flatbuffers_define_scalar_field(10, NdbProfile, damus_donation, flatbuffers_int32, int32_t, INT32_C(0)) -__flatbuffers_define_scalar_field(11, NdbProfile, damus_donation_v2, flatbuffers_int32, int32_t, INT32_C(0)) +__flatbuffers_define_string_field(0, NdbProfile, name, 0) +__flatbuffers_define_string_field(1, NdbProfile, website, 0) +__flatbuffers_define_string_field(2, NdbProfile, about, 0) +__flatbuffers_define_string_field(3, NdbProfile, lud16, 0) +__flatbuffers_define_string_field(4, NdbProfile, banner, 0) +__flatbuffers_define_string_field(5, NdbProfile, display_name, 0) +__flatbuffers_define_scalar_field(6, NdbProfile, reactions, flatbuffers_bool, flatbuffers_bool_t, UINT8_C(1)) +__flatbuffers_define_string_field(7, NdbProfile, picture, 0) +__flatbuffers_define_string_field(8, NdbProfile, nip05, 0) +__flatbuffers_define_scalar_field(9, NdbProfile, damus_donation, flatbuffers_int32, int32_t, INT32_C(0)) +__flatbuffers_define_scalar_field(10, NdbProfile, damus_donation_v2, flatbuffers_int32, int32_t, INT32_C(0)) #include "flatcc/flatcc_epilogue.h" diff --git a/bindings/c/profile_verifier.h b/bindings/c/profile_verifier.h @@ -14,18 +14,17 @@ static int NdbProfile_verify_table(flatcc_table_verifier_descriptor_t *td); static int NdbProfile_verify_table(flatcc_table_verifier_descriptor_t *td) { int ret; - if ((ret = flatcc_verify_string_field(td, 0, 0) /* json */)) return ret; - if ((ret = flatcc_verify_string_field(td, 1, 0) /* name */)) return ret; - if ((ret = flatcc_verify_string_field(td, 2, 0) /* website */)) return ret; - if ((ret = flatcc_verify_string_field(td, 3, 0) /* about */)) return ret; - if ((ret = flatcc_verify_string_field(td, 4, 0) /* lud16 */)) return ret; - if ((ret = flatcc_verify_string_field(td, 5, 0) /* banner */)) return ret; - if ((ret = flatcc_verify_string_field(td, 6, 0) /* display_name */)) return ret; - if ((ret = flatcc_verify_field(td, 7, 1, 1) /* reactions */)) return ret; - if ((ret = flatcc_verify_string_field(td, 8, 0) /* picture */)) return ret; - if ((ret = flatcc_verify_string_field(td, 9, 0) /* nip05 */)) return ret; - if ((ret = flatcc_verify_field(td, 10, 4, 4) /* damus_donation */)) return ret; - if ((ret = flatcc_verify_field(td, 11, 4, 4) /* damus_donation_v2 */)) return ret; + if ((ret = flatcc_verify_string_field(td, 0, 0) /* name */)) return ret; + if ((ret = flatcc_verify_string_field(td, 1, 0) /* website */)) return ret; + if ((ret = flatcc_verify_string_field(td, 2, 0) /* about */)) return ret; + if ((ret = flatcc_verify_string_field(td, 3, 0) /* lud16 */)) return ret; + if ((ret = flatcc_verify_string_field(td, 4, 0) /* banner */)) return ret; + if ((ret = flatcc_verify_string_field(td, 5, 0) /* display_name */)) return ret; + if ((ret = flatcc_verify_field(td, 6, 1, 1) /* reactions */)) return ret; + if ((ret = flatcc_verify_string_field(td, 7, 0) /* picture */)) return ret; + if ((ret = flatcc_verify_string_field(td, 8, 0) /* nip05 */)) return ret; + if ((ret = flatcc_verify_field(td, 9, 4, 4) /* damus_donation */)) return ret; + if ((ret = flatcc_verify_field(td, 10, 4, 4) /* damus_donation_v2 */)) return ret; return flatcc_verify_ok; } diff --git a/bindings/swift/NdbProfile.swift b/bindings/swift/NdbProfile.swift @@ -14,24 +14,21 @@ public struct NdbProfile: FlatBufferObject, Verifiable { public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) } private enum VTOFFSET: VOffset { - case json = 4 - case name = 6 - case website = 8 - case about = 10 - case lud16 = 12 - case banner = 14 - case displayName = 16 - case reactions = 18 - case picture = 20 - case nip05 = 22 - case damusDonation = 24 - case damusDonationV2 = 26 + case name = 4 + case website = 6 + case about = 8 + case lud16 = 10 + case banner = 12 + case displayName = 14 + case reactions = 16 + case picture = 18 + case nip05 = 20 + case damusDonation = 22 + case damusDonationV2 = 24 var v: Int32 { Int32(self.rawValue) } var p: VOffset { self.rawValue } } - public var json: String? { let o = _accessor.offset(VTOFFSET.json.v); return o == 0 ? nil : _accessor.string(at: o) } - public var jsonSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.json.v) } public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) } public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) } public var website: String? { let o = _accessor.offset(VTOFFSET.website.v); return o == 0 ? nil : _accessor.string(at: o) } @@ -51,8 +48,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable { public var nip05SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.nip05.v) } public var damusDonation: Int32 { let o = _accessor.offset(VTOFFSET.damusDonation.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) } public var damusDonationV2: Int32 { let o = _accessor.offset(VTOFFSET.damusDonationV2.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) } - public static func startNdbProfile(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 12) } - public static func add(json: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: json, at: VTOFFSET.json.p) } + public static func startNdbProfile(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) } public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) } public static func add(website: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: website, at: VTOFFSET.website.p) } public static func add(about: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: about, at: VTOFFSET.about.p) } @@ -68,7 +64,6 @@ public struct NdbProfile: FlatBufferObject, Verifiable { public static func endNdbProfile(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end } public static func createNdbProfile( _ fbb: inout FlatBufferBuilder, - jsonOffset json: Offset = Offset(), nameOffset name: Offset = Offset(), websiteOffset website: Offset = Offset(), aboutOffset about: Offset = Offset(), @@ -82,7 +77,6 @@ public struct NdbProfile: FlatBufferObject, Verifiable { damusDonationV2: Int32 = 0 ) -> Offset { let __start = NdbProfile.startNdbProfile(&fbb) - NdbProfile.add(json: json, &fbb) NdbProfile.add(name: name, &fbb) NdbProfile.add(website: website, &fbb) NdbProfile.add(about: about, &fbb) @@ -99,7 +93,6 @@ public struct NdbProfile: FlatBufferObject, Verifiable { public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable { var _v = try verifier.visitTable(at: position) - try _v.visit(field: VTOFFSET.json.p, fieldName: "json", required: false, type: ForwardOffset<String>.self) try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self) try _v.visit(field: VTOFFSET.website.p, fieldName: "website", required: false, type: ForwardOffset<String>.self) try _v.visit(field: VTOFFSET.about.p, fieldName: "about", required: false, type: ForwardOffset<String>.self) diff --git a/schemas/profile.fbs b/schemas/profile.fbs @@ -1,7 +1,5 @@ table NdbProfile { - json:string; - name:string; website:string; about:string; @@ -12,7 +10,6 @@ table NdbProfile { picture:string; nip05:string; - damus_donation:int; damus_donation_v2:int; }