Skip to content
Snippets Groups Projects
Select Git revision
  • f922d8581ccf1deaa8c39ae926242a12c288eb3a
  • master default
  • notifications_test_ndf
  • main_ud_local_ndf
  • crust-integration
  • new-client
  • internal_build
  • FE-1054_test_net_ndf
  • FE-1053_change_retry_behavior
  • app_modularization_refactor
  • FE_1020_remove_version_check
  • FE-992_android_migration
  • XX-4094_add_fact_panic
  • FE-990_retry_reset_request
  • development
  • 2.92
  • 2.9
  • 2.8
  • 2.7
  • 2.5
  • 2.3
  • 2.2
  • 2.1
  • 2.04
  • 2.03
  • 2.02
26 results

Gemfile

Blame
  • This project manages its dependencies using Bundler. Learn more
    params.go 3.23 KiB
    ///////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                          //
    //                                                                           //
    // Use of this source code is governed by a license that can be found in the //
    // LICENSE file                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    
    package xxdk
    
    // params.go define the high level parameters structures (which embed E2E and
    // CMIX params respectively) that are passed down into the core xxdk modules.
    
    import (
    	"encoding/json"
    
    	"gitlab.com/elixxir/client/auth"
    	"gitlab.com/elixxir/client/cmix"
    	"gitlab.com/elixxir/client/e2e"
    	"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
    	"gitlab.com/elixxir/client/e2e/rekey"
    )
    
    // CMIXParams contains the parameters for Network tracking and for specific CMIX
    // messaging settings.
    //
    // FIXME: this breakdown could be cleaner and is an unfortunate side effect of
    //        several refactors of the codebase.
    type CMIXParams struct {
    	Network cmix.Params
    	CMIX    cmix.CMIXParams
    }
    
    // E2EParams holds all the settings for e2e and it's various submodules.
    //
    // Note that Base wraps cmix.CMIXParams to control message send params, so that
    // xxdk library users should copy the desired settings to both.
    // FIXME: this should not wrap a copy of cmix.CMIXParams.
    type E2EParams struct {
    	Session        session.Params
    	Base           e2e.Params
    	Rekey          rekey.Params
    	EphemeralRekey rekey.Params
    	Auth           auth.Params
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    // CMix Params Helper Functions                                               //
    ////////////////////////////////////////////////////////////////////////////////
    
    // GetDefaultCMixParams returns a new CMIXParams with the default parameters.
    func GetDefaultCMixParams() CMIXParams {
    	return CMIXParams{
    		Network: cmix.GetDefaultParams(),
    		CMIX:    cmix.GetDefaultCMIXParams(),
    	}
    }
    
    // Unmarshal fills an empty object with the deserialized contents of the JSON
    // data.
    func (p *CMIXParams) Unmarshal(jsonData []byte) error {
    	return json.Unmarshal(jsonData, p)
    }
    
    // Marshal creates JSON data of the object.
    func (p *CMIXParams) Marshal() ([]byte, error) {
    	return json.Marshal(p)
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    // E2E Params Helper Functions                                                //
    ////////////////////////////////////////////////////////////////////////////////
    
    // GetDefaultE2EParams returns a new E2EParams with the default parameters.
    func GetDefaultE2EParams() E2EParams {
    	return E2EParams{
    		Session:        session.GetDefaultParams(),
    		Base:           e2e.GetDefaultParams(),
    		Rekey:          rekey.GetDefaultParams(),
    		EphemeralRekey: rekey.GetDefaultEphemeralParams(),
    		Auth:           auth.GetDefaultParams(),
    	}
    }
    
    // Unmarshal fills an empty object with the deserialized contents of the JSON
    // data.
    func (p *E2EParams) Unmarshal(jsonData []byte) error {
    	return json.Unmarshal(jsonData, p)
    }
    
    // Marshal creates JSON data of the object.
    func (p *E2EParams) Marshal() ([]byte, error) {
    	return json.Marshal(p)
    }