github.com/stafiprotocol/go-substrate-rpc-client@v1.4.7/pkg/scale/Readme.md (about)

     1  This code was copied over with many thanks from https://github.com/Joystream/parity-codec-go/tree/develop/withreflect
     2  
     3  # Chainsafe vs Joystream scale codec
     4  
     5  - Code quality wise Chainsafe codec is better because of proper handling(no panic), use of standard interfaces, more tests and good comments.
     6  - However Joystream codec has better usability because of the way it handles structs or unknown types by providing two interfaces.
     7      ```
     8      // Encodeable is an interface that defines a custom encoding rules for a data type.
     9      // Should be defined for structs (not pointers to them).
    10      // See OptionBool for an example implementation.
    11      type Encodeable interface {
    12          // ParityEncode encodes and write this structure into a stream
    13          ParityEncode(encoder Encoder)
    14      }
    15  
    16      // Decodeable is an interface that defines a custom encoding rules for a data type.
    17      // Should be defined for pointers to structs.
    18      // See OptionBool for an example implementation.
    19      type Decodeable interface {
    20          // ParityDecode populates this structure from a stream (overwriting the current contents), return false on failure
    21          ParityDecode(decoder Decoder)
    22      }
    23      ```
    24      This helped in debugging issues because structs could be debugged one field at a time when decoding and encoding. It was easy to see the progress of decoding for example by looking at already decoded struct fields and the buffere thats passed in within the decoder struct. This could have been implemented in client code for Chainsafe codec in hindsight, but just dealing with RPC execution issues was of higher priority.
    25      
    26  It's better if the good features of both could be integrated together to create a nicer library.