Select Git revision
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