sardariuss / MotokoStableBTree

https://forum.dfinity.org/t/icdevs-org-bounty-24-stablebtree-mokoko-up-to-10k/14867

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to insert Blobs instead of Nat8 arrays?

fermartz opened this issue · comments

Hey @sardariuss thanks for creating this library.

I was wondering if the value of the btree can be a Blob or is a requirement to be a Nat8 array?

let value : Blob = "\00\00\00\66";
 btreemap_.insert(key, value);
 
commented

Hey @fermatz, sorry for the late answer.

It is possible to use any type really, but you need to give to the btree a converter to its "internal representation" of data.

On the main branch, the lib uses [Nat8] indeed, so you need to give a converter from Blob <-> [Nat8]

On the recenter improvement/useBlob, the lib uses Blobs internally, so you can give it a "passthrough" converter, that directly returns your Blob. Have a look a bytesConverter.mo.

That being said, may I ask what is your intend of using this library?
Because that library has some limitations and hasn't been quite used yet for now, I would advise using the hashmap from ZhenyaUsenko instead: https://github.com/ZhenyaUsenko/motoko-hash-map/tree/master