MaxSize method should estimate the maximum possible size of the struct that needs to be decoded taking into account limits (such as max for the collections). Any value that overflows such MaxSize for the type must be discarded with an error.
Size method is an optimization for Encode. Without Size consumer is forced to allocate memory multiple times for a single encode operation, instead it should be possible to use the following code.
encoder := scale.NewEncoder(bytes.NewBuffer(make([]byte, typed.Size()))
MaxSize method should estimate the maximum possible size of the struct that needs to be decoded taking into account limits (such as
maxfor the collections). Any value that overflows such MaxSize for the type must be discarded with an error.Size method is an optimization for Encode. Without Size consumer is forced to allocate memory multiple times for a single encode operation, instead it should be possible to use the following code.