From cfb0debaed3a1ee191dd3d41c84a2ccdf3df65b7 Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Wed, 12 Oct 2022 23:55:00 -0400 Subject: pkg/api/api0: Add pdata storage interface --- pkg/api/api0/storage.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pkg/api/api0/storage.go (limited to 'pkg/api/api0/storage.go') diff --git a/pkg/api/api0/storage.go b/pkg/api/api0/storage.go new file mode 100644 index 0000000..cf7b078 --- /dev/null +++ b/pkg/api/api0/storage.go @@ -0,0 +1,17 @@ +package api0 + +import "crypto/sha256" + +// PdataStorage stores player data for users. It should not make any assumptions +// on the contents of the stored blobs (including validity). It may compress the +// stored data. It must be safe for concurrent use. +type PdataStorage interface { + // GetPdataCached gets the pdata for uid. If there is not any pdata for uid, + // ok is false. If the provided hash is nonzero and the current pdata + // matches, buf is nil. If another error occurs, buf is nil, ok is false, + // and err is non-nil. + GetPdataCached(uid uint64, sha256 [sha256.Size]byte) (buf []byte, exists bool, err error) + + // SetPdata sets the raw pdata for uid. + SetPdata(uid uint64, buf []byte) (err error) +} -- cgit v1.2.3