Happy Sunday, everyone.
Today's post is a bit of a story and a ramble about a development journey I went on this morning. I've been working on a new tool to help manage the settings for Hive communities, and it sent me down a rabbit hole trying to understand how community accounts are actually created.
The Community Settings Manager
First, here's a sneak peek at the tool I'm building. The goal is to create a simple interface for community owners and moderators to update properties like the title, description, and rules. It's still a work in progress, but it should be ready soon-ish.
While building this, I wanted to understand the process for creating a community. I knew the account names were hive-XXXXXX
, but I wasn't sure how the numbers were generated or if there was a specific protocol to follow.
Down the Rabbit Hole
So, I started by reading the official documentation, which says:
Communities are registered by creating an on-chain account which conforms to
/^hive-[1-3]\d{4,6}$/
, with the first digit signifying the type.
The documentation goes on to explain the different types:
- Topics (type 1): Anyone can post.
- Journals (type 2): Only members can post, but anyone can comment.
- Councils (type 3): Only members can post and comment.
I never knew "Journals" and "Councils" were even a thing! This seemed like a cool feature to support.
My next question was: how are the numbers in the account name generated? I initially started digging through the condenser (hive.blog) source code, but after a while, I got tired of searching. So, I turned to my new favorite tool, DeepWiki, and had it ingest the condenser and wallet repositories.
After my coffee, I finally had some answers. DeepWiki analyzed the wallet source code and told me this:
No Collision Detection: The system does not check if the account already exists before attempting creation. It simply generates a random number and hopes it's not taken, as you suspected.
Oof. But it gets more interesting:
The current implementation doesn't match the documented regex pattern... The actual code only generates numbers in the 100000-199999 range (effectively type "1" communities), and doesn't implement the type system or the full range mentioned in the documentation.
So, it seems the functionality for creating "Journals" and "Councils" might not even be implemented, despite being in the documentation. I'd rather know this now than build options into my tool that aren't really options.
The investigation continues!
As always, Michael Garcia a.k.a. TheCrazyGM