Skip to content
Snippets Groups Projects
Select Git revision
  • dfb89f0fd4f8c37b70dab72bc5cf73de6c6cd0ba
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

session.go

Blame
  • session.go 12.14 KiB
    ////////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 Privategrity Corporation                                   /
    //                                                                             /
    // All rights reserved.                                                        /
    ////////////////////////////////////////////////////////////////////////////////
    
    // Session object definition
    
    package storage
    
    import (
    	"github.com/pkg/errors"
    	"gitlab.com/elixxir/client/globals"
    	userInterface "gitlab.com/elixxir/client/interfaces/user"
    	"gitlab.com/elixxir/client/storage/cmix"
    	"gitlab.com/elixxir/client/storage/conversation"
    	"gitlab.com/elixxir/client/storage/e2e"
    	"gitlab.com/elixxir/client/storage/partition"
    	"gitlab.com/elixxir/client/storage/user"
    	"gitlab.com/elixxir/client/storage/utility"
    	"gitlab.com/elixxir/client/storage/versioned"
    	"gitlab.com/elixxir/crypto/csprng"
    	"gitlab.com/elixxir/crypto/cyclic"
    	"gitlab.com/elixxir/crypto/fastRNG"
    	"gitlab.com/elixxir/crypto/large"
    	"gitlab.com/elixxir/ekv"
    	"gitlab.com/xx_network/crypto/signature/rsa"
    	"gitlab.com/xx_network/primitives/id"
    	"gitlab.com/xx_network/primitives/ndf"
    	"sync"
    	"testing"
    )
    
    // Number of rounds to store in the CheckedRound buffer
    const CheckRoundsMaxSize = 1000000 / 64
    
    // Session object, backed by encrypted filestore
    type Session struct {
    	kv  *versioned.KV
    	mux sync.RWMutex
    
    	//memoized data
    	regStatus RegistrationStatus
    	baseNdf   *ndf.NetworkDefinition
    
    	//sub-stores
    	e2e              *e2e.Store
    	cmix             *cmix.Store
    	user             *user.User
    	conversations    *conversation.Store
    	partition        *partition.Store
    	criticalMessages *utility.E2eMessageBuffer
    	garbledMessages  *utility.MeteredCmixMessageBuffer
    	checkedRounds    *utility.KnownRounds
    }
    
    // Initialize a new Session object
    func initStore(baseDir, password string) (*Session, error) {
    	fs, err := ekv.NewFilestore(baseDir, password)
    	var s *Session
    	if err != nil {
    		return nil, errors.WithMessage(err,
    			"Failed to create storage session")
    	}
    
    	s = &Session{
    		kv: versioned.NewKV(fs),
    	}
    
    	return s, nil