From c820e89cb751c3b7b6285c74afb18570282dc077 Mon Sep 17 00:00:00 2001 From: lash Date: Wed, 11 Dec 2024 19:13:13 +0000 Subject: [PATCH] Segment tx userdata types, add internals docs --- common/db.go | 15 +++++---------- doc/data.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 doc/data.md diff --git a/common/db.go b/common/db.go index f20dbab..a5cf1c1 100644 --- a/common/db.go +++ b/common/db.go @@ -19,20 +19,12 @@ import ( type DataTyp uint16 const ( - // TODO: Seems unused - DATA_ACCOUNT DataTyp = iota - // TODO: Seems unused, only read not written - DATA_ACCOUNT_CREATED // API Tracking id to follow status of account creation - DATA_TRACKING_ID + DATA_TRACKING_ID = iota // EVM address returned from API on account creation DATA_PUBLIC_KEY - // TODO: Seems unused - DATA_CUSTODIAL_ID // Currently active PIN used to authenticate ussd state change requests DATA_ACCOUNT_PIN - // TODO: Seems unused - DATA_ACCOUNT_STATUS // The first name of the user DATA_FIRST_NAME // The last name of the user @@ -75,7 +67,10 @@ const ( // List of voucher EVM addresses for vouchers valid in the user context. DATA_VOUCHER_ADDRESSES // List of senders for valid transactions in the user context. - DATA_TX_SENDERS +) + +const ( + DATA_TX_SENDERS = 512 + iota // List of recipients for valid transactions in the user context. DATA_TX_RECIPIENTS // List of voucher values for valid transactions in the user context. diff --git a/doc/data.md b/doc/data.md new file mode 100644 index 0000000..7a41f0c --- /dev/null +++ b/doc/data.md @@ -0,0 +1,28 @@ +# Internals + +## Version + +This document describes component versions: + +* `urdt-ussd` `v0.5.0-beta` +* `go-vise` `v0.2.2` + + +## User profile data + +All user profile items are stored under keys matching the user's session id, prefixed with the 8-bit value `git.defalsify.org/vise.git/db.DATATYPE_USERDATA` (32), and followed with a 16-big big-endian value subprefix. + +For example, given the sessionId `+254123` and the key `git.grassecon.net/urdt-ussd/common.DATA_PUBLIC_KEY` (2) will be stored under the key: + +``` +0x322b3235343132330002 + +prefix sessionid subprefix +32 2b323534313233 0002 +``` + +### Sub-prefixes + +All sub-prefixes are defined as constants in the `git.grassecon.net/urdt-ussd/common` package. The constant names have the prefix `DATA_` + +Please refer to inline godoc documentation for the `git.grassecon.net/urdt-ussd/common` package for details on each data item.