bug in next_state
There is a next_state function in util whose purpose is to check for updates in the data getting input in the put function and generate the state key in the metadata according. Basically it is meant for conflict resolution.
The websockets-tokio example in the examples directory is actually connecting and communicating with a real GUN network! Each time the code runs it sends a put request for the "pos" key. I am primarily using it to test the next_state function.
The bug is in this segment here:
log::info!("{:?}", node[key]);
log::info!("{:?}", val);
if &node[key] == val {
n
} else {
n + 1
}
Vaguely, it adds one if the value is new and keeps it the same if the value is the same.
You will see this in the log:
String("3")
Number(3)
String("5")
Number(5)
The number values getting sent to us from other nodes are getting sent as strings, so the values will always be read as different! I am not sure if this is an issue in the Rust or JS implementation. Also if you have a string value such as "cat" you will see String("\"cat\"") and String("cat") being compared.
I'm not sure if this is an issue with JS stringifying or Rust's parsing of the data, but it seems our graph is getting built with the wrong types.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.