nostrdb

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

commit 335cd21e6600d972485121d6c1b515d8b354753d
parent a5d5428c467e32d215419b74a140ef0adde2869e
Author: William Casarin <jb55@jb55.com>
Date:   Sat, 26 Aug 2023 22:16:46 -0700

profiles: add lud06 field

Diffstat:
MMakefile | 4++--
Mbindings/c/profile_builder.h | 9++++++---
Mbindings/c/profile_json_parser.h | 53++++++++++++++++++++++++++++++++++-------------------
Mbindings/c/profile_reader.h | 1+
Mbindings/c/profile_verifier.h | 1+
Mbindings/swift/NdbProfile.swift | 11+++++++++--
Mschemas/profile.fbs | 3++-
7 files changed, 55 insertions(+), 27 deletions(-)

diff --git a/Makefile b/Makefile @@ -15,10 +15,10 @@ C_BINDINGS_COMMON=bindings/c/flatbuffers_common_builder.h bindings/c/flatbuffers C_BINDINGS=$(C_BINDINGS_COMMON) $(C_BINDINGS_PROFILE) $(C_BINDINGS_META) BINDINGS=bindings -lib: benches test - all: lib bindings +lib: benches test + bindings: bindings-swift bindings-c check: test diff --git a/bindings/c/profile_builder.h b/bindings/c/profile_builder.h @@ -20,16 +20,16 @@ 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, 11) +__flatbuffers_build_table(flatbuffers_, NdbProfile, 12) #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_bool_t v6, flatbuffers_string_ref_t v7,\ - flatbuffers_string_ref_t v8, int32_t v9, int32_t v10 + flatbuffers_string_ref_t v8, int32_t v9, int32_t v10, flatbuffers_string_ref_t v11 #define __NdbProfile_call_args ,\ v0, v1, v2, v3,\ v4, v5, v6, v7,\ - v8, v9, v10 + v8, v9, v10, v11 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) @@ -44,6 +44,7 @@ __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) +__flatbuffers_build_string_field(11, flatbuffers_, NdbProfile_lud06, NdbProfile) static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbProfile_formal_args) { @@ -58,6 +59,7 @@ static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbP || NdbProfile_nip05_add(B, v8) || NdbProfile_damus_donation_add(B, v9) || NdbProfile_damus_donation_v2_add(B, v10) + || NdbProfile_lud06_add(B, v11) || NdbProfile_reactions_add(B, v6)) { return 0; } @@ -78,6 +80,7 @@ static NdbProfile_ref_t NdbProfile_clone(flatbuffers_builder_t *B, NdbProfile_ta || NdbProfile_nip05_pick(B, t) || NdbProfile_damus_donation_pick(B, t) || NdbProfile_damus_donation_v2_pick(B, t) + || NdbProfile_lud06_pick(B, t) || NdbProfile_reactions_pick(B, t)) { return 0; } diff --git a/bindings/c/profile_json_parser.h b/bindings/c/profile_json_parser.h @@ -33,12 +33,12 @@ static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const uint64_t w; *result = 0; - if (flatcc_builder_start_table(ctx->ctx, 11)) goto failed; + if (flatcc_builder_start_table(ctx->ctx, 12)) goto failed; buf = flatcc_json_parser_object_start(ctx, buf, end, &more); while (more) { buf = flatcc_json_parser_symbol_start(ctx, buf, end); w = flatcc_json_parser_symbol_part(buf, end); - if (w < 0x6c75643136000000) { /* branch "lud16" */ + if (w < 0x6c75643036000000) { /* branch "lud06" */ if (w < 0x64616d75735f646f) { /* branch "damus_do" */ if ((w & 0xffffffffffff0000) == 0x62616e6e65720000) { /* "banner" */ buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 6); @@ -137,31 +137,46 @@ static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const } /* descend "display_" */ } /* descend "damus_do" */ } /* branch "damus_do" */ - } else { /* branch "lud16" */ + } else { /* branch "lud06" */ if (w < 0x6e69703035000000) { /* branch "nip05" */ - if ((w & 0xffffffff00000000) == 0x6e616d6500000000) { /* "name" */ - buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 4); - if (mark != buf) { - buf = flatcc_json_parser_build_string(ctx, buf, end, &ref); - if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 0))) goto failed; - *pref = ref; - } else { - buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end); - } - } else { /* "name" */ - if ((w & 0xffffffffff000000) == 0x6c75643136000000) { /* "lud16" */ + if (w < 0x6c75643136000000) { /* branch "lud16" */ + if ((w & 0xffffffffff000000) == 0x6c75643036000000) { /* "lud06" */ buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 5); if (mark != buf) { buf = flatcc_json_parser_build_string(ctx, buf, end, &ref); - if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 3))) goto failed; + if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 11))) goto failed; *pref = ref; } else { buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end); } - } else { /* "lud16" */ + } else { /* "lud06" */ buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end); - } /* "lud16" */ - } /* "name" */ + } /* "lud06" */ + } else { /* branch "lud16" */ + if ((w & 0xffffffff00000000) == 0x6e616d6500000000) { /* "name" */ + buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 4); + if (mark != buf) { + buf = flatcc_json_parser_build_string(ctx, buf, end, &ref); + if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 0))) goto failed; + *pref = ref; + } else { + buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end); + } + } else { /* "name" */ + if ((w & 0xffffffffff000000) == 0x6c75643136000000) { /* "lud16" */ + buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 5); + if (mark != buf) { + buf = flatcc_json_parser_build_string(ctx, buf, end, &ref); + if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 3))) goto failed; + *pref = ref; + } else { + buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end); + } + } else { /* "lud16" */ + buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end); + } /* "lud16" */ + } /* "name" */ + } /* branch "lud16" */ } else { /* branch "nip05" */ if (w < 0x7069637475726500) { /* branch "picture" */ if ((w & 0xffffffffff000000) == 0x6e69703035000000) { /* "nip05" */ @@ -233,7 +248,7 @@ static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const } /* branch "reaction" */ } /* branch "picture" */ } /* branch "nip05" */ - } /* branch "lud16" */ + } /* branch "lud06" */ buf = flatcc_json_parser_object_end(ctx, buf, end, &more); } if (ctx->error) goto failed; diff --git a/bindings/c/profile_reader.h b/bindings/c/profile_reader.h @@ -57,6 +57,7 @@ __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)) +__flatbuffers_define_string_field(11, NdbProfile, lud06, 0) #include "flatcc/flatcc_epilogue.h" diff --git a/bindings/c/profile_verifier.h b/bindings/c/profile_verifier.h @@ -25,6 +25,7 @@ static int NdbProfile_verify_table(flatcc_table_verifier_descriptor_t *td) 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; + if ((ret = flatcc_verify_string_field(td, 11, 0) /* lud06 */)) return ret; return flatcc_verify_ok; } diff --git a/bindings/swift/NdbProfile.swift b/bindings/swift/NdbProfile.swift @@ -25,6 +25,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable { case nip05 = 20 case damusDonation = 22 case damusDonationV2 = 24 + case lud06 = 26 var v: Int32 { Int32(self.rawValue) } var p: VOffset { self.rawValue } } @@ -48,7 +49,9 @@ 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: 11) } + public var lud06: String? { let o = _accessor.offset(VTOFFSET.lud06.v); return o == 0 ? nil : _accessor.string(at: o) } + public var lud06SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.lud06.v) } + public static func startNdbProfile(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 12) } 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) } @@ -61,6 +64,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable { public static func add(nip05: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: nip05, at: VTOFFSET.nip05.p) } public static func add(damusDonation: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damusDonation, def: 0, at: VTOFFSET.damusDonation.p) } public static func add(damusDonationV2: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damusDonationV2, def: 0, at: VTOFFSET.damusDonationV2.p) } + public static func add(lud06: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: lud06, at: VTOFFSET.lud06.p) } 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, @@ -74,7 +78,8 @@ public struct NdbProfile: FlatBufferObject, Verifiable { pictureOffset picture: Offset = Offset(), nip05Offset nip05: Offset = Offset(), damusDonation: Int32 = 0, - damusDonationV2: Int32 = 0 + damusDonationV2: Int32 = 0, + lud06Offset lud06: Offset = Offset() ) -> Offset { let __start = NdbProfile.startNdbProfile(&fbb) NdbProfile.add(name: name, &fbb) @@ -88,6 +93,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable { NdbProfile.add(nip05: nip05, &fbb) NdbProfile.add(damusDonation: damusDonation, &fbb) NdbProfile.add(damusDonationV2: damusDonationV2, &fbb) + NdbProfile.add(lud06: lud06, &fbb) return NdbProfile.endNdbProfile(&fbb, start: __start) } @@ -104,6 +110,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable { try _v.visit(field: VTOFFSET.nip05.p, fieldName: "nip05", required: false, type: ForwardOffset<String>.self) try _v.visit(field: VTOFFSET.damusDonation.p, fieldName: "damusDonation", required: false, type: Int32.self) try _v.visit(field: VTOFFSET.damusDonationV2.p, fieldName: "damusDonationV2", required: false, type: Int32.self) + try _v.visit(field: VTOFFSET.lud06.p, fieldName: "lud06", required: false, type: ForwardOffset<String>.self) _v.finish() } } diff --git a/schemas/profile.fbs b/schemas/profile.fbs @@ -9,9 +9,10 @@ table NdbProfile { reactions:bool = true; picture:string; nip05:string; - damus_donation:int; damus_donation_v2:int; + lud06:string; } root_type NdbProfile; +