Reputation: 317
I notice when I try and use Borsh to serialize/deserialize I'll get errors when the data sizes don't match. For example, if I have an array in the account data and then I go and try and add another element. If I don't already have a placeholder data item in there with dummy values in the fields the serialization attempt will fail. Am I doing something wrong or is this just the way that it is and I just have to accept that?
Upvotes: 5
Views: 3231
Reputation: 1015
If you are passing in the &[u8] of data to try_from_slice but the overall account data size is greater than your data you will get that borsh error as it defaults to checking the deserialized length with the overall slice length (or something like that):
Upvotes: 7