I’m not sure I understand registers.
When I read the developer docs, I understand files are immutable, and registers are mutable.
I have made a little blocks/tetris like game people can see it by running:
$ ant file download 261f85f041460702dd3598e543808ff9835e748786999fced5c1803533eac644 marks-blocks-game
This works perfectly, however if I want to change anything I must upload a new file.
So my understanding is we have registers, that can be mutated, and as such I should be able to make a register point marks-blocks-game
to the file id, and update this if I upload a new version/file.
So I tested this out and made a register.
$ ant register create autonomi-blocks-game testing
🔗 Connected to the Network
Creating register with name: autonomi-blocks-game
✅ Register created at address: af273bfee32503d70fabf40bbf6a12e57af3a1656948e42e3f0905939e640eb5bc8363c6f5a6638a455c1be79d1c8ec6
With name: autonomi-blocks-game
And initial value: [testing]
Total cost: 0.00000000000000000000022411078500 AttoTokens
Next, I try and read that register, and I do get the value I expect:
$ ant register get --name autonomi-blocks-game
🔗 Connected to the Network
Getting register with name: autonomi-blocks-game
✅ Register found at: autonomi-blocks-game
With value: [testing]
So, next up, I try and update it to my current game version:
$ ant register edit --name autonomi-blocks-game "261f85f041460702dd3598e543808ff9835e748786999fced5c1803533eac644"
🔗 Connected to the Network
Error:
0: Invalid register value length: 64, expected something within 32 bytes
Location:
ant-cli/src/commands/register.rs:89
This is my first surprise/problem. Reading the docs, I can indeed see the register is limited to 32 bytes, but the files seem to have 64 byte hashes. I’m not sure why? I’m I misunderstanding the point of the register?
But I also just wanted to see the register mutating, so I decided to update it to something smaller anyway.
$ ant register edit --name autonomi-blocks-game "edit-test"
🔗 Connected to the Network
Attempting to update register at autonomi-blocks-game with new value: edit-test
✅ Successfully updated register
With value: [edit-test]
Total cost: 0.00000000000000000000000055883640 AttoTokens
It seems like it works. Woohoo!
But then I try and read the register again:
$ ant register get --name autonomi-blocks-game
🔗 Connected to the Network
Getting register with name: autonomi-blocks-game
✅ Register found at: autonomi-blocks-game
With value: [testing]
But I seem to get the original value of the register.
So I guess, my TL;DR; questions are:
- Why are file hashes 64 bytes but registers are only allowed values of a max 32 bytes?
- Why did updating the value of a register then reading it again not show the new value?