The datamap contains basic information on the file. It has a u64 file size and a table of entries where each entry contains chunk# u64, post-encryption-hash 32 bytes, pre-encryption-hash 32 bytes, and size of chunk u64
What I cannot seem to find from the code is the transformation done to go from the pre or post hash to the xor address that the chunk is stored at. The xor address of the chunk must be derived from the chunk entry in the datamap somehow and I wish to learn what it is.
The pre hash is internal to the SE algo. The chunk is stored at the post hash, i.e. the hash of its contents. That and the xor address are 32byte arrays
The post hash is the XorName and is not the xor address. The logs speak differently. The code also shows that the post hash of type XorName is not the xor address. The xor address is derived from the post hash and I’ve used that xor address to be able to get quotes from nodes around that xor address, so I have shown that the post hash is not the xor address
The post hash is the hash of the content of the chunk. That is where there chunk is stored.
Are you saying the chunks are not stored at that hash?
(BTW I have not checked the code for xorname verses post hash verses xor address, but in my mind these are all 32 byte addresses and all the same 32 byte array)
The log file uses the one debug! with {key:?} to output the 2 values
debug!(“Getting the closest peers to {key:?}”);
This outputs the log line shown above
…sn_networking] Getting the closest peers to NetworkAddress::ChunkAddress(post hash - xor address)
where post hash is a shortened version of the XorName and full 32 bytes of the xor address. In this case the XorName is the post hash for the chunk which is stored in the datamap
I tried doing sha256 on the XorName, but it did not give me the xor address. BTW this isn’t to do with a distance calculation. this is from the self encryption post encryption hash to give the xor address used to store the chunk.
Does digest do something to the bytes?
EDIT: Oh wait, I was doing sha256 on the hex representation and not the binary. Let me get onto that soontm
Found my problem was a fundamental one and one I am ashamed of doing, and that is applying the sha256 on the (character) hex representation of the post hash rather than using the binary version.
Learning how it all connects together. I was asked to help oversee a project that is taking a lot longer to get going than even I expected. (procurement etc). The company is dragging its feet getting the stuff
So I have been spending some time learning about how the network connects together at a deeper level. And testing out things we’ve assumed would be correct. Like is the distribution of self encrypted chunks really the random distribution we expected. And as it turns out it was pretty good.
Also in the process I am getting a handle on the rust language. I wasn’t going to learn yet another language in my 7th decade of life but here I am LOL It is an interesting one. How far I’ll go in learning it I am not sure, but I guess being able to read it is the easy part.