code: func NewProtocolMsg(code uint64, msg interface{}) ([]byte, error) {
  
  	rlpdata, err := rlp.EncodeToBytes(msg)
  	if err != nil {
  		return nil, err
  	}
  
  	// TODO verify that nested structs cannot be used in rlp
  	smsg := &ProtocolMsg{
  		Code:    code,
  		Size:    uint32(len(rlpdata)),
  		Payload: rlpdata,
  	}
  
  	return rlp.EncodeToBytes(smsg)
  }
docs: // Creates a ProtocolMsg