1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

move pkgs

This commit is contained in:
Sergey Cherepanov 2022-10-17 14:11:55 +03:00 committed by Mikhail Iudin
parent 5689863046
commit daa9bb1df0
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
152 changed files with 569 additions and 1771 deletions

View file

@ -34,9 +34,9 @@ proto:
build:
@$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app))
@$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/common/app))
go build -v -o bin/anytype-node -ldflags "$(FLAGS)" cmd/node/node.go
build-consensus:
@$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app))
@$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/common/app))
go build -v -o bin/consensus-node -ldflags "$(FLAGS)" github.com/anytypeio/go-anytype-infrastructure-experiments/cmd/consensusnode

View file

@ -1,13 +1,13 @@
package account
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
commonaccount "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
)
type service struct {

View file

@ -2,8 +2,8 @@ package badgerprovider
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/dgraph-io/badger/v3"
)

View file

@ -3,11 +3,11 @@ package clientcache
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/client/clientspace"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ocache"
"time"
)

View file

@ -2,14 +2,14 @@ package clientspace
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ocache"
"time"
)
@ -29,14 +29,14 @@ type Service interface {
}
type service struct {
conf config.Space
conf config2.Space
spaceCache ocache.OCache
commonSpace commonspace.Service
spaceStorageProvider storage.SpaceStorageProvider
}
func (s *service) Init(a *app.App) (err error) {
s.conf = a.MustComponent(config.CName).(*config.Config).Space
s.conf = a.MustComponent(config2.CName).(*config2.Config).Space
s.commonSpace = a.MustComponent(commonspace.CName).(commonspace.Service)
s.spaceStorageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider)
s.spaceCache = ocache.New(

View file

@ -1,6 +1,6 @@
package document
import "github.com/anytypeio/go-anytype-infrastructure-experiments/app"
import "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
type Service interface {
app.Component

View file

@ -1,7 +1,7 @@
package storage
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
)
type aclKeys struct {

View file

@ -3,8 +3,8 @@ package storage
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/dgraph-io/badger/v3"
)

View file

@ -3,7 +3,7 @@ package storage
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
spacestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/dgraph-io/badger/v3"
"sync"
)
@ -12,7 +12,7 @@ type spaceStorage struct {
spaceId string
objDb *badger.DB
keys spaceKeys
aclStorage storage.ListStorage
aclStorage storage2.ListStorage
header *spacesyncproto.RawSpaceHeaderWithId
mx sync.Mutex
}
@ -81,11 +81,11 @@ func (s *spaceStorage) ID() (string, error) {
return s.spaceId, nil
}
func (s *spaceStorage) TreeStorage(id string) (storage.TreeStorage, error) {
func (s *spaceStorage) TreeStorage(id string) (storage2.TreeStorage, error) {
return newTreeStorage(s.objDb, s.spaceId, id)
}
func (s *spaceStorage) CreateTreeStorage(payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) {
func (s *spaceStorage) CreateTreeStorage(payload storage2.TreeStorageCreatePayload) (ts storage2.TreeStorage, err error) {
// we have mutex here, so we prevent overwriting the heads of a tree on concurrent creation
s.mx.Lock()
defer s.mx.Unlock()
@ -93,7 +93,7 @@ func (s *spaceStorage) CreateTreeStorage(payload storage.TreeStorageCreatePayloa
return createTreeStorage(s.objDb, s.spaceId, payload)
}
func (s *spaceStorage) ACLStorage() (storage.ListStorage, error) {
func (s *spaceStorage) ACLStorage() (storage2.ListStorage, error) {
return s.aclStorage, nil
}

View file

@ -1,7 +1,7 @@
package storage
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/client/badgerprovider"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/dgraph-io/badger/v3"

View file

@ -2,8 +2,8 @@ package storage
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/dgraph-io/badger/v3"
)
@ -14,7 +14,7 @@ type treeStorage struct {
root *treechangeproto.RawTreeChangeWithId
}
func newTreeStorage(db *badger.DB, spaceId, treeId string) (ts storage.TreeStorage, err error) {
func newTreeStorage(db *badger.DB, spaceId, treeId string) (ts storage2.TreeStorage, err error) {
keys := newTreeKeys(spaceId, treeId)
err = db.View(func(txn *badger.Txn) error {
_, err := txn.Get(keys.RootIdKey())
@ -43,14 +43,14 @@ func newTreeStorage(db *badger.DB, spaceId, treeId string) (ts storage.TreeStora
return
}
func createTreeStorage(db *badger.DB, spaceId string, payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) {
func createTreeStorage(db *badger.DB, spaceId string, payload storage2.TreeStorageCreatePayload) (ts storage2.TreeStorage, err error) {
keys := newTreeKeys(spaceId, payload.TreeId)
if hasDB(db, keys.RootIdKey()) {
err = storage.ErrTreeExists
err = storage2.ErrTreeExists
return
}
err = db.Update(func(txn *badger.Txn) error {
heads := storage.CreateHeadsPayload(payload.Heads)
heads := storage2.CreateHeadsPayload(payload.Heads)
for _, ch := range payload.Changes {
err = txn.Set(keys.RawChangeKey(ch.Id), ch.GetRawChange())
@ -97,16 +97,16 @@ func (t *treeStorage) Heads() (heads []string, err error) {
headsBytes, err := getDB(t.db, t.keys.HeadsKey())
if err != nil {
if err == badger.ErrKeyNotFound {
err = storage.ErrUnknownTreeId
err = storage2.ErrUnknownTreeId
}
return
}
heads = storage.ParseHeads(headsBytes)
heads = storage2.ParseHeads(headsBytes)
return
}
func (t *treeStorage) SetHeads(heads []string) (err error) {
payload := storage.CreateHeadsPayload(heads)
payload := storage2.CreateHeadsPayload(heads)
return putDB(t.db, t.keys.HeadsKey(), payload)
}
@ -118,7 +118,7 @@ func (t *treeStorage) GetRawChange(ctx context.Context, id string) (raw *treecha
res, err := getDB(t.db, t.keys.RawChangeKey(id))
if err != nil {
if err == badger.ErrKeyNotFound {
err = storage.ErrUnknownTreeId
err = storage2.ErrUnknownTreeId
}
return
}

View file

@ -4,8 +4,8 @@ import (
"context"
"flag"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/metric"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure"

View file

@ -5,13 +5,13 @@ import (
"context"
"flag"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/consensusclient"
"github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/consensusproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/consensusproto/consensuserr"

View file

@ -4,15 +4,15 @@ import (
"context"
"flag"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/node/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace"
"github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace/nodecache"

View file

@ -3,12 +3,12 @@ package main
import (
"flag"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/peer"
cconfig "github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/peer"
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
@ -42,8 +42,8 @@ func main() {
}
flag.Parse()
var configs []config.Config
var nodes []config.Node
var configs []config2.Config
var nodes []config2.Node
for _, n := range nodesMap.Nodes {
cfg, err := genNodeConfig(n.Addresses, n.APIPort)
if err != nil {
@ -51,7 +51,7 @@ func main() {
}
configs = append(configs, cfg)
node := config.Node{
node := config2.Node{
PeerId: cfg.Account.PeerId,
Address: cfg.GrpcServer.ListenAddrs[0],
SigningKey: cfg.Account.SigningKey,
@ -68,7 +68,7 @@ func main() {
}
consConfigs = append(consConfigs, cfg)
node := config.Node{
node := config2.Node{
PeerId: cfg.Account.PeerId,
Address: cfg.GrpcServer.ListenAddrs[0],
SigningKey: cfg.Account.SigningKey,
@ -124,48 +124,48 @@ func main() {
}
}
func genNodeConfig(addresses []string, apiPort string) (config.Config, error) {
func genNodeConfig(addresses []string, apiPort string) (config2.Config, error) {
encKey, _, err := encryptionkey.GenerateRandomRSAKeyPair(2048)
if err != nil {
return config.Config{}, err
return config2.Config{}, err
}
signKey, _, err := signingkey.GenerateRandomEd25519KeyPair()
if err != nil {
return config.Config{}, err
return config2.Config{}, err
}
encEncKey, err := keys.EncodeKeyToString(encKey)
if err != nil {
return config.Config{}, err
return config2.Config{}, err
}
encSignKey, err := keys.EncodeKeyToString(signKey)
if err != nil {
return config.Config{}, err
return config2.Config{}, err
}
peerID, err := peer.IDFromSigningPubKey(signKey.GetPublic())
if err != nil {
return config.Config{}, err
return config2.Config{}, err
}
return config.Config{
Anytype: config.Anytype{SwarmKey: "/key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec"},
GrpcServer: config.GrpcServer{
return config2.Config{
Anytype: config2.Anytype{SwarmKey: "/key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec"},
GrpcServer: config2.GrpcServer{
ListenAddrs: addresses,
TLS: false,
},
Storage: config.Storage{Path: "db"},
Account: config.Account{
Storage: config2.Storage{Path: "db"},
Account: config2.Account{
PeerId: peerID.String(),
SigningKey: encSignKey,
EncryptionKey: encEncKey,
},
APIServer: config.APIServer{
APIServer: config2.APIServer{
Port: apiPort,
},
Space: config.Space{
Space: config2.Space{
GCTTL: 60,
SyncPeriod: 10,
},
@ -199,11 +199,11 @@ func genConsensusConfig(addresses []string) (cconfig.Config, error) {
}
return cconfig.Config{
GrpcServer: config.GrpcServer{
GrpcServer: config2.GrpcServer{
ListenAddrs: addresses,
TLS: false,
},
Account: config.Account{
Account: config2.Account{
PeerId: peerID.String(),
SigningKey: encSignKey,
EncryptionKey: encEncKey,

View file

@ -1,9 +1,9 @@
package account
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/account"
)
const CName = "common.account"

View file

@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"go.uber.org/zap"
"os"
"runtime"

View file

@ -8,7 +8,7 @@ import (
context "context"
reflect "reflect"
app "github.com/anytypeio/go-anytype-infrastructure-experiments/app"
app "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
cache "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
gomock "github.com/golang/mock/gomock"
)

View file

@ -4,9 +4,9 @@ package cache
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree/updatelistener"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
)
const CName = "commonspace.cache"

View file

@ -8,7 +8,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff"
"go.uber.org/zap"
"strings"
)

View file

@ -1,12 +1,12 @@
package diffservice
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice/mock_diffservice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage/mock_storage"
mock_storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage/mock_storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff/mock_ldiff"
mock_storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage/mock_storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff/mock_ldiff"
"github.com/golang/mock/gomock"
"testing"
)

View file

@ -9,7 +9,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/rpcerr"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff"
"go.uber.org/zap"
"time"
)

View file

@ -3,7 +3,7 @@ package diffservice
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache/mock_cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff"
@ -12,9 +12,9 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage/mock_storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf/mock_nodeconf"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
mock_aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage/mock_storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff/mock_ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
mock_aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage/mock_storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff/mock_ldiff"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"storj.io/drpc"

View file

@ -1,7 +1,7 @@
package diffservice
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice/mock_diffservice"
"github.com/golang/mock/gomock"
"testing"

View file

@ -3,9 +3,9 @@ package commonspace
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
aclrecordproto2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"hash/fnv"
"math/rand"
"time"
@ -68,7 +68,7 @@ func storagePayloadForSpaceCreate(payload SpaceCreatePayload) (storagePayload st
}
// preparing acl
aclRoot := &aclrecordproto.ACLRoot{
aclRoot := &aclrecordproto2.ACLRoot{
Identity: identity,
EncryptionKey: encPubKey,
SpaceId: spaceId,
@ -144,7 +144,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload st
}
// deriving and encrypting read key
readKey, err := aclrecordproto.ACLReadKeyDerive(signPrivKey, encPrivKey)
readKey, err := aclrecordproto2.ACLReadKeyDerive(signPrivKey, encPrivKey)
if err != nil {
return
}
@ -160,7 +160,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload st
}
// preparing acl
aclRoot := &aclrecordproto.ACLRoot{
aclRoot := &aclrecordproto2.ACLRoot{
Identity: identity,
EncryptionKey: encPubKey,
SpaceId: spaceId,
@ -182,7 +182,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload st
return
}
func marshalACLRoot(aclRoot *aclrecordproto.ACLRoot, key signingkey.PrivKey) (rawWithId *aclrecordproto.RawACLRecordWithId, err error) {
func marshalACLRoot(aclRoot *aclrecordproto2.ACLRoot, key signingkey.PrivKey) (rawWithId *aclrecordproto2.RawACLRecordWithId, err error) {
marshalledRoot, err := aclRoot.Marshal()
if err != nil {
return
@ -191,7 +191,7 @@ func marshalACLRoot(aclRoot *aclrecordproto.ACLRoot, key signingkey.PrivKey) (ra
if err != nil {
return
}
raw := &aclrecordproto.RawACLRecord{
raw := &aclrecordproto2.RawACLRecord{
Payload: marshalledRoot,
Signature: signature,
}
@ -203,7 +203,7 @@ func marshalACLRoot(aclRoot *aclrecordproto.ACLRoot, key signingkey.PrivKey) (ra
if err != nil {
return
}
rawWithId = &aclrecordproto.RawACLRecordWithId{
rawWithId = &aclrecordproto2.RawACLRecordWithId{
Payload: marshalledRaw,
Id: aclHeadId,
}

View file

@ -3,7 +3,7 @@ package remotediff
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff"
)
type Client interface {

View file

@ -4,7 +4,7 @@ import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ldiff"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"

View file

@ -2,15 +2,15 @@ package commonspace
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice"
config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
)
const CName = "common.commonspace"
@ -29,7 +29,7 @@ type Service interface {
}
type service struct {
config config.Space
config config2.Space
configurationService nodeconf.Service
storageProvider storage.SpaceStorageProvider
cache cache.TreeCache
@ -37,7 +37,7 @@ type service struct {
}
func (s *service) Init(a *app.App) (err error) {
s.config = a.MustComponent(config.CName).(*config.Config).Space
s.config = a.MustComponent(config2.CName).(*config2.Config).Space
s.storageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider)
s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service)
s.cache = a.MustComponent(cache.CName).(cache.TreeCache)

View file

@ -10,11 +10,11 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree/updatelistener"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
tree2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"sync"
)
@ -47,9 +47,9 @@ type Space interface {
SpaceSyncRpc() RpcHandler
DeriveTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree.ObjectTree, error)
CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree.ObjectTree, error)
BuildTree(ctx context.Context, id string, listener updatelistener.UpdateListener) (tree.ObjectTree, error)
DeriveTree(ctx context.Context, payload tree2.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree2.ObjectTree, error)
CreateTree(ctx context.Context, payload tree2.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree2.ObjectTree, error)
BuildTree(ctx context.Context, id string, listener updatelistener.UpdateListener) (tree2.ObjectTree, error)
Close() error
}
@ -94,15 +94,15 @@ func (s *space) DiffService() diffservice.DiffService {
return s.diffService
}
func (s *space) DeriveTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree.ObjectTree, error) {
func (s *space) DeriveTree(ctx context.Context, payload tree2.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree2.ObjectTree, error) {
return synctree.DeriveSyncTree(ctx, payload, s.syncService.SyncClient(), listener, s.aclList, s.storage.CreateTreeStorage)
}
func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree.ObjectTree, error) {
func (s *space) CreateTree(ctx context.Context, payload tree2.ObjectTreeCreatePayload, listener updatelistener.UpdateListener) (tree2.ObjectTree, error) {
return synctree.CreateSyncTree(ctx, payload, s.syncService.SyncClient(), listener, s.aclList, s.storage.CreateTreeStorage)
}
func (s *space) BuildTree(ctx context.Context, id string, listener updatelistener.UpdateListener) (t tree.ObjectTree, err error) {
func (s *space) BuildTree(ctx context.Context, id string, listener updatelistener.UpdateListener) (t tree2.ObjectTree, err error) {
getTreeRemote := func() (*spacesyncproto.ObjectSyncMessage, error) {
// TODO: add empty context handling (when this is not happening due to head update)
peerId, err := syncservice.GetPeerIdFromStreamContext(ctx)
@ -116,11 +116,11 @@ func (s *space) BuildTree(ctx context.Context, id string, listener updatelistene
}
store, err := s.storage.TreeStorage(id)
if err != nil && err != treestorage.ErrUnknownTreeId {
if err != nil && err != storage2.ErrUnknownTreeId {
return
}
if err == treestorage.ErrUnknownTreeId {
if err == storage2.ErrUnknownTreeId {
var resp *spacesyncproto.ObjectSyncMessage
resp, err = getTreeRemote()
if err != nil {
@ -128,7 +128,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener updatelistene
}
fullSyncResp := resp.GetContent().GetFullSyncResponse()
payload := treestorage.TreeStorageCreatePayload{
payload := storage2.TreeStorageCreatePayload{
TreeId: resp.TreeId,
RootRawChange: resp.RootChange,
Changes: fullSyncResp.Changes,
@ -136,7 +136,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener updatelistene
}
// basically building tree with inmemory storage and validating that it was without errors
err = tree.ValidateRawTree(payload, s.aclList)
err = tree2.ValidateRawTree(payload, s.aclList)
if err != nil {
return
}
@ -146,7 +146,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener updatelistene
return
}
}
return synctree.BuildSyncTree(ctx, s.syncService.SyncClient(), store.(treestorage.TreeStorage), listener, s.aclList)
return synctree.BuildSyncTree(ctx, s.syncService.SyncClient(), store.(storage2.TreeStorage), listener, s.aclList)
}
func (s *space) Close() error {

View file

@ -2,7 +2,7 @@
package spacesyncproto
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"storj.io/drpc"
)

View file

@ -5,8 +5,8 @@ package spacesyncproto
import (
fmt "fmt"
aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"

View file

@ -5,12 +5,12 @@
package mock_storage
import (
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
reflect "reflect"
app "github.com/anytypeio/go-anytype-infrastructure-experiments/app"
app "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
spacesyncproto "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
storage0 "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
gomock "github.com/golang/mock/gomock"
)
@ -119,10 +119,10 @@ func (m *MockSpaceStorage) EXPECT() *MockSpaceStorageMockRecorder {
}
// ACLStorage mocks base method.
func (m *MockSpaceStorage) ACLStorage() (storage0.ListStorage, error) {
func (m *MockSpaceStorage) ACLStorage() (storage2.ListStorage, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ACLStorage")
ret0, _ := ret[0].(storage0.ListStorage)
ret0, _ := ret[0].(storage2.ListStorage)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -148,10 +148,10 @@ func (mr *MockSpaceStorageMockRecorder) Close() *gomock.Call {
}
// CreateTreeStorage mocks base method.
func (m *MockSpaceStorage) CreateTreeStorage(arg0 storage0.TreeStorageCreatePayload) (storage0.TreeStorage, error) {
func (m *MockSpaceStorage) CreateTreeStorage(arg0 storage2.TreeStorageCreatePayload) (storage2.TreeStorage, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateTreeStorage", arg0)
ret0, _ := ret[0].(storage0.TreeStorage)
ret0, _ := ret[0].(storage2.TreeStorage)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -208,10 +208,10 @@ func (mr *MockSpaceStorageMockRecorder) StoredIds() *gomock.Call {
}
// TreeStorage mocks base method.
func (m *MockSpaceStorage) TreeStorage(arg0 string) (storage0.TreeStorage, error) {
func (m *MockSpaceStorage) TreeStorage(arg0 string) (storage2.TreeStorage, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "TreeStorage", arg0)
ret0, _ := ret[0].(storage0.TreeStorage)
ret0, _ := ret[0].(storage2.TreeStorage)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View file

@ -3,10 +3,10 @@ package storage
import (
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
)
const CName = "commonspace.storage"
@ -15,9 +15,9 @@ var ErrSpaceStorageExists = errors.New("space storage exists")
var ErrSpaceStorageMissing = errors.New("space storage missing")
type SpaceStorage interface {
storage.Storage
storage.Provider
ACLStorage() (storage.ListStorage, error)
storage2.Storage
storage2.Provider
ACLStorage() (storage2.ListStorage, error)
SpaceHeader() (*spacesyncproto.RawSpaceHeaderWithId, error)
StoredIds() ([]string, error)
Close() error

View file

@ -5,11 +5,11 @@
package mock_syncservice
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
reflect "reflect"
spacesyncproto "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
tree "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
gomock "github.com/golang/mock/gomock"
)

View file

@ -3,9 +3,9 @@ package syncservice
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/slice"
)
type RequestFactory interface {

View file

@ -4,8 +4,8 @@ import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/slice"
)
type syncHandler struct {

View file

@ -7,9 +7,9 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache/mock_cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice/mock_syncservice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
mock_tree "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree/mock_objecttree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree/mock_objecttree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"sync"

View file

@ -3,7 +3,7 @@ package syncservice
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/rpcerr"

View file

@ -4,30 +4,30 @@ import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree/updatelistener"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
tree2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
)
// SyncTree sends head updates to sync service and also sends new changes to update listener
type SyncTree struct {
tree.ObjectTree
tree2.ObjectTree
syncClient syncservice.SyncClient
listener updatelistener.UpdateListener
}
var createDerivedObjectTree = tree.CreateDerivedObjectTree
var createObjectTree = tree.CreateObjectTree
var buildObjectTree = tree.BuildObjectTree
var createDerivedObjectTree = tree2.CreateDerivedObjectTree
var createObjectTree = tree2.CreateObjectTree
var buildObjectTree = tree2.BuildObjectTree
func DeriveSyncTree(
ctx context.Context,
payload tree.ObjectTreeCreatePayload,
payload tree2.ObjectTreeCreatePayload,
syncClient syncservice.SyncClient,
listener updatelistener.UpdateListener,
aclList list.ACLList,
createStorage storage.TreeStorageCreatorFunc) (t tree.ObjectTree, err error) {
createStorage storage.TreeStorageCreatorFunc) (t tree2.ObjectTree, err error) {
t, err = createDerivedObjectTree(payload, aclList, createStorage)
if err != nil {
return
@ -45,11 +45,11 @@ func DeriveSyncTree(
func CreateSyncTree(
ctx context.Context,
payload tree.ObjectTreeCreatePayload,
payload tree2.ObjectTreeCreatePayload,
syncClient syncservice.SyncClient,
listener updatelistener.UpdateListener,
aclList list.ACLList,
createStorage storage.TreeStorageCreatorFunc) (t tree.ObjectTree, err error) {
createStorage storage.TreeStorageCreatorFunc) (t tree2.ObjectTree, err error) {
t, err = createObjectTree(payload, aclList, createStorage)
if err != nil {
return
@ -70,7 +70,7 @@ func BuildSyncTree(
syncClient syncservice.SyncClient,
treeStorage storage.TreeStorage,
listener updatelistener.UpdateListener,
aclList list.ACLList) (t tree.ObjectTree, err error) {
aclList list.ACLList) (t tree2.ObjectTree, err error) {
return buildSyncTree(ctx, syncClient, treeStorage, listener, aclList)
}
@ -79,7 +79,7 @@ func buildSyncTree(
syncClient syncservice.SyncClient,
treeStorage storage.TreeStorage,
listener updatelistener.UpdateListener,
aclList list.ACLList) (t tree.ObjectTree, err error) {
aclList list.ACLList) (t tree2.ObjectTree, err error) {
t, err = buildObjectTree(treeStorage, aclList)
if err != nil {
return
@ -96,7 +96,7 @@ func buildSyncTree(
return
}
func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeContent) (res tree.AddResult, err error) {
func (s *SyncTree) AddContent(ctx context.Context, content tree2.SignableChangeContent) (res tree2.AddResult, err error) {
res, err = s.ObjectTree.AddContent(ctx, content)
if err != nil {
return
@ -106,17 +106,17 @@ func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeCo
return
}
func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*treechangeproto.RawTreeChangeWithId) (res tree.AddResult, err error) {
func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*treechangeproto.RawTreeChangeWithId) (res tree2.AddResult, err error) {
res, err = s.ObjectTree.AddRawChanges(ctx, changes...)
if err != nil {
return
}
switch res.Mode {
case tree.Nothing:
case tree2.Nothing:
return
case tree.Append:
case tree2.Append:
s.listener.Update(s)
case tree.Rebuild:
case tree2.Rebuild:
s.listener.Rebuild(s)
}
@ -125,6 +125,6 @@ func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*treechangeprot
return
}
func (s *SyncTree) Tree() tree.ObjectTree {
func (s *SyncTree) Tree() tree2.ObjectTree {
return s
}

View file

@ -7,20 +7,20 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice/mock_syncservice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree/updatelistener"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree/updatelistener/mock_updatelistener"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list/mock_list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage/mock_storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
mock_tree "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree/mock_objecttree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list/mock_list"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage/mock_storage"
tree2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree/mock_objecttree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"testing"
)
type syncTreeMatcher struct {
objTree tree.ObjectTree
objTree tree2.ObjectTree
client syncservice.SyncClient
listener updatelistener.UpdateListener
}
@ -45,11 +45,11 @@ func Test_DeriveSyncTree(t *testing.T) {
updateListenerMock := mock_updatelistener.NewMockUpdateListener(ctrl)
syncClientMock := mock_syncservice.NewMockSyncClient(ctrl)
aclListMock := mock_list.NewMockACLList(ctrl)
createStorage := storage.TreeStorageCreatorFunc(func(payload storage.TreeStorageCreatePayload) (storage.TreeStorage, error) {
createStorage := storage2.TreeStorageCreatorFunc(func(payload storage2.TreeStorageCreatePayload) (storage2.TreeStorage, error) {
return nil, nil
})
objTreeMock := mock_tree.NewMockObjectTree(ctrl)
createDerivedObjectTree = func(payload tree.ObjectTreeCreatePayload, l list.ACLList, create storage.TreeStorageCreatorFunc) (objTree tree.ObjectTree, err error) {
createDerivedObjectTree = func(payload tree2.ObjectTreeCreatePayload, l list.ACLList, create storage2.TreeStorageCreatorFunc) (objTree tree2.ObjectTree, err error) {
require.Equal(t, l, aclListMock)
return objTreeMock, nil
}
@ -57,7 +57,7 @@ func Test_DeriveSyncTree(t *testing.T) {
syncClientMock.EXPECT().CreateHeadUpdate(syncTreeMatcher{objTreeMock, syncClientMock, updateListenerMock}, gomock.Nil()).Return(headUpdate)
syncClientMock.EXPECT().BroadcastAsync(gomock.Eq(headUpdate)).Return(nil)
_, err := DeriveSyncTree(ctx, tree.ObjectTreeCreatePayload{}, syncClientMock, updateListenerMock, aclListMock, createStorage)
_, err := DeriveSyncTree(ctx, tree2.ObjectTreeCreatePayload{}, syncClientMock, updateListenerMock, aclListMock, createStorage)
require.NoError(t, err)
}
@ -69,11 +69,11 @@ func Test_CreateSyncTree(t *testing.T) {
updateListenerMock := mock_updatelistener.NewMockUpdateListener(ctrl)
syncClientMock := mock_syncservice.NewMockSyncClient(ctrl)
aclListMock := mock_list.NewMockACLList(ctrl)
createStorage := storage.TreeStorageCreatorFunc(func(payload storage.TreeStorageCreatePayload) (storage.TreeStorage, error) {
createStorage := storage2.TreeStorageCreatorFunc(func(payload storage2.TreeStorageCreatePayload) (storage2.TreeStorage, error) {
return nil, nil
})
objTreeMock := mock_tree.NewMockObjectTree(ctrl)
createObjectTree = func(payload tree.ObjectTreeCreatePayload, l list.ACLList, create storage.TreeStorageCreatorFunc) (objTree tree.ObjectTree, err error) {
createObjectTree = func(payload tree2.ObjectTreeCreatePayload, l list.ACLList, create storage2.TreeStorageCreatorFunc) (objTree tree2.ObjectTree, err error) {
require.Equal(t, l, aclListMock)
return objTreeMock, nil
}
@ -81,7 +81,7 @@ func Test_CreateSyncTree(t *testing.T) {
syncClientMock.EXPECT().CreateHeadUpdate(syncTreeMatcher{objTreeMock, syncClientMock, updateListenerMock}, gomock.Nil()).Return(headUpdate)
syncClientMock.EXPECT().BroadcastAsync(gomock.Eq(headUpdate)).Return(nil)
_, err := CreateSyncTree(ctx, tree.ObjectTreeCreatePayload{}, syncClientMock, updateListenerMock, aclListMock, createStorage)
_, err := CreateSyncTree(ctx, tree2.ObjectTreeCreatePayload{}, syncClientMock, updateListenerMock, aclListMock, createStorage)
require.NoError(t, err)
}
@ -95,7 +95,7 @@ func Test_BuildSyncTree(t *testing.T) {
aclListMock := mock_list.NewMockACLList(ctrl)
storageMock := mock_storage.NewMockTreeStorage(ctrl)
objTreeMock := mock_tree.NewMockObjectTree(ctrl)
buildObjectTree = func(store storage.TreeStorage, l list.ACLList) (objTree tree.ObjectTree, err error) {
buildObjectTree = func(store storage2.TreeStorage, l list.ACLList) (objTree tree2.ObjectTree, err error) {
require.Equal(t, aclListMock, l)
require.Equal(t, store, storageMock)
return objTreeMock, nil
@ -109,9 +109,9 @@ func Test_BuildSyncTree(t *testing.T) {
t.Run("AddRawChanges update", func(t *testing.T) {
changes := []*treechangeproto.RawTreeChangeWithId{{Id: "some"}}
expectedRes := tree.AddResult{
expectedRes := tree2.AddResult{
Added: changes,
Mode: tree.Append,
Mode: tree2.Append,
}
objTreeMock.EXPECT().AddRawChanges(gomock.Any(), gomock.Eq(changes)).
Return(expectedRes, nil)
@ -126,9 +126,9 @@ func Test_BuildSyncTree(t *testing.T) {
t.Run("AddRawChanges rebuild", func(t *testing.T) {
changes := []*treechangeproto.RawTreeChangeWithId{{Id: "some"}}
expectedRes := tree.AddResult{
expectedRes := tree2.AddResult{
Added: changes,
Mode: tree.Rebuild,
Mode: tree2.Rebuild,
}
objTreeMock.EXPECT().AddRawChanges(gomock.Any(), gomock.Eq(changes)).
Return(expectedRes, nil)
@ -143,9 +143,9 @@ func Test_BuildSyncTree(t *testing.T) {
t.Run("AddRawChanges nothing", func(t *testing.T) {
changes := []*treechangeproto.RawTreeChangeWithId{{Id: "some"}}
expectedRes := tree.AddResult{
expectedRes := tree2.AddResult{
Added: changes,
Mode: tree.Nothing,
Mode: tree2.Nothing,
}
objTreeMock.EXPECT().AddRawChanges(gomock.Any(), gomock.Eq(changes)).
Return(expectedRes, nil)
@ -157,11 +157,11 @@ func Test_BuildSyncTree(t *testing.T) {
t.Run("AddContent", func(t *testing.T) {
changes := []*treechangeproto.RawTreeChangeWithId{{Id: "some"}}
content := tree.SignableChangeContent{
content := tree2.SignableChangeContent{
Data: []byte("abcde"),
}
expectedRes := tree.AddResult{
Mode: tree.Append,
expectedRes := tree2.AddResult{
Mode: tree2.Append,
Added: changes,
}
objTreeMock.EXPECT().AddContent(gomock.Any(), gomock.Eq(content)).

View file

@ -5,9 +5,9 @@
package mock_updatelistener
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
reflect "reflect"
tree "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
gomock "github.com/golang/mock/gomock"
)

View file

@ -1,7 +1,9 @@
//go:generate mockgen -destination mock_updatelistener/mock_updatelistener.go github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree/updatelistener UpdateListener
package updatelistener
import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
)
type UpdateListener interface {
Update(tree tree.ObjectTree)

View file

@ -2,8 +2,8 @@ package config
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"gopkg.in/yaml.v3"
"io/ioutil"
)

View file

@ -1,7 +1,7 @@
package config
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"go.uber.org/zap"
)

View file

@ -2,8 +2,8 @@ package metric
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -24,16 +24,16 @@ type Metric interface {
type metric struct {
registry *prometheus.Registry
config config.Metric
config config2.Metric
}
type configSource interface {
GetMetric() config.Metric
GetMetric() config2.Metric
}
func (m *metric) Init(a *app.App) (err error) {
m.registry = prometheus.NewRegistry()
m.config = a.MustComponent(config.CName).(configSource).GetMetric()
m.config = a.MustComponent(config2.CName).(configSource).GetMetric()
return nil
}

View file

@ -3,11 +3,11 @@ package dialer
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/libp2p/go-libp2p-core/sec"
"go.uber.org/zap"
"net"

View file

@ -3,11 +3,11 @@ package pool
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ocache"
"math/rand"
"time"
)

View file

@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer"
"github.com/stretchr/testify/assert"

View file

@ -2,11 +2,11 @@ package server
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/metric"
secure2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/prometheus/client_golang/prometheus"
"github.com/zeebo/errs"
"go.uber.org/zap"
@ -32,11 +32,11 @@ type DRPCServer interface {
}
type configGetter interface {
GetGRPCServer() config.GrpcServer
GetGRPCServer() config2.GrpcServer
}
type drpcServer struct {
config config.GrpcServer
config config2.GrpcServer
drpcServer *drpcserver.Server
transport secure2.Service
listeners []secure2.ContextListener
@ -46,7 +46,7 @@ type drpcServer struct {
}
func (s *drpcServer) Init(a *app.App) (err error) {
s.config = a.MustComponent(config.CName).(configGetter).GetGRPCServer()
s.config = a.MustComponent(config2.CName).(configGetter).GetGRPCServer()
s.transport = a.MustComponent(secure2.CName).(secure2.Service)
s.metric = a.MustComponent(metric.CName).(metric.Metric)
return nil

View file

@ -2,11 +2,11 @@ package secure
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
commonaccount "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/sec"
libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls"

View file

@ -1,12 +1,12 @@
package nodeconf
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys"
encryptionkey2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
signingkey2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-chash"
)
@ -36,8 +36,8 @@ type service struct {
type Node struct {
Address string
PeerId string
SigningKey signingkey.PubKey
EncryptionKey encryptionkey.PubKey
SigningKey signingkey2.PubKey
EncryptionKey encryptionkey2.PubKey
}
func (n *Node) Id() string {
@ -49,7 +49,7 @@ func (n *Node) Capacity() float64 {
}
func (s *service) Init(a *app.App) (err error) {
conf := a.MustComponent(config.CName).(*config.Config)
conf := a.MustComponent(config2.CName).(*config2.Config)
s.accountId = conf.Account.PeerId
config := &configuration{
@ -100,10 +100,10 @@ func (s *service) ConsensusPeers() []string {
}
func nodeFromConfigNode(
n config.Node) (*Node, error) {
n config2.Node) (*Node, error) {
decodedSigningKey, err := keys.DecodeKeyFromString(
n.SigningKey,
signingkey.UnmarshalEd25519PrivateKey,
signingkey2.UnmarshalEd25519PrivateKey,
nil)
if err != nil {
return nil, err
@ -111,7 +111,7 @@ func nodeFromConfigNode(
decodedEncryptionKey, err := keys.DecodeKeyFromString(
n.EncryptionKey,
encryptionkey.NewEncryptionRsaPrivKeyFromBytes,
encryptionkey2.NewEncryptionRsaPrivKeyFromBytes,
nil)
if err != nil {
return nil, err

View file

@ -0,0 +1,12 @@
package account
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
)
type AccountData struct { // TODO: create a convenient constructor for this
Identity []byte // public key
SignKey signingkey.PrivKey
EncKey encryptionkey.PrivKey
}

View file

@ -1,6 +1,8 @@
package aclrecordproto
import "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric"
)
func ACLReadKeyDerive(signKey []byte, encKey []byte) (*symmetric.Key, error) {
concBuf := make([]byte, 0, len(signKey)+len(encKey))

View file

@ -0,0 +1,28 @@
package common
import (
signingkey2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
)
type Keychain struct {
keys map[string]signingkey2.PubKey
}
func NewKeychain() *Keychain {
return &Keychain{
keys: make(map[string]signingkey2.PubKey),
}
}
func (k *Keychain) GetOrAdd(identity string) (signingkey2.PubKey, error) {
if key, exists := k.keys[identity]; exists {
return key, nil
}
res, err := signingkey2.NewSigningEd25519PubKeyFromBytes([]byte(identity))
if err != nil {
return nil, err
}
k.keys[identity] = res.(signingkey2.PubKey)
return res.(signingkey2.PubKey), nil
}

View file

@ -1,9 +1,9 @@
package list
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/cid"
"github.com/gogo/protobuf/proto"
)

View file

@ -4,12 +4,12 @@ import (
"bytes"
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
aclrecordproto2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
signingkey2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric"
"github.com/gogo/protobuf/proto"
"go.uber.org/zap"
"hash/fnv"
@ -30,17 +30,17 @@ var ErrIncorrectRoot = errors.New("incorrect root")
type UserPermissionPair struct {
Identity string
Permission aclrecordproto.ACLUserPermissions
Permission aclrecordproto2.ACLUserPermissions
}
type ACLState struct {
id string
currentReadKeyHash uint64
userReadKeys map[uint64]*symmetric.Key
userStates map[string]*aclrecordproto.ACLUserState
userInvites map[string]*aclrecordproto.ACLUserInvite
userStates map[string]*aclrecordproto2.ACLUserState
userInvites map[string]*aclrecordproto2.ACLUserInvite
encryptionKey encryptionkey.PrivKey
signingKey signingkey.PrivKey
signingKey signingkey2.PrivKey
identity string
permissionsAtRecord map[string][]UserPermissionPair
@ -50,7 +50,7 @@ type ACLState struct {
func newACLStateWithKeys(
id string,
signingKey signingkey.PrivKey,
signingKey signingkey2.PrivKey,
encryptionKey encryptionkey.PrivKey) (*ACLState, error) {
identity, err := signingKey.Raw()
if err != nil {
@ -62,8 +62,8 @@ func newACLStateWithKeys(
signingKey: signingKey,
encryptionKey: encryptionKey,
userReadKeys: make(map[uint64]*symmetric.Key),
userStates: make(map[string]*aclrecordproto.ACLUserState),
userInvites: make(map[string]*aclrecordproto.ACLUserInvite),
userStates: make(map[string]*aclrecordproto2.ACLUserState),
userInvites: make(map[string]*aclrecordproto2.ACLUserInvite),
permissionsAtRecord: make(map[string][]UserPermissionPair),
}, nil
}
@ -72,8 +72,8 @@ func newACLState(id string) *ACLState {
return &ACLState{
id: id,
userReadKeys: make(map[uint64]*symmetric.Key),
userStates: make(map[string]*aclrecordproto.ACLUserState),
userInvites: make(map[string]*aclrecordproto.ACLUserInvite),
userStates: make(map[string]*aclrecordproto2.ACLUserState),
userInvites: make(map[string]*aclrecordproto2.ACLUserInvite),
permissionsAtRecord: make(map[string][]UserPermissionPair),
}
}
@ -111,16 +111,16 @@ func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermiss
func (st *ACLState) applyRecord(record *ACLRecord) (err error) {
if record.Id == st.id {
root, ok := record.Model.(*aclrecordproto.ACLRoot)
root, ok := record.Model.(*aclrecordproto2.ACLRoot)
if !ok {
return ErrIncorrectRoot
}
return st.applyRoot(root)
}
aclData := &aclrecordproto.ACLData{}
aclData := &aclrecordproto2.ACLData{}
if record.Model != nil {
aclData = record.Model.(*aclrecordproto.ACLData)
aclData = record.Model.(*aclrecordproto2.ACLData)
} else {
err = proto.Unmarshal(record.Data, aclData)
if err != nil {
@ -148,7 +148,7 @@ func (st *ACLState) applyRecord(record *ACLRecord) (err error) {
return nil
}
func (st *ACLState) applyRoot(root *aclrecordproto.ACLRoot) (err error) {
func (st *ACLState) applyRoot(root *aclrecordproto2.ACLRoot) (err error) {
if st.signingKey != nil && st.encryptionKey != nil {
err = st.saveReadKeyFromRoot(root)
if err != nil {
@ -157,16 +157,16 @@ func (st *ACLState) applyRoot(root *aclrecordproto.ACLRoot) (err error) {
}
// adding user to the list
userState := &aclrecordproto.ACLUserState{
userState := &aclrecordproto2.ACLUserState{
Identity: root.Identity,
EncryptionKey: root.EncryptionKey,
Permissions: aclrecordproto.ACLUserPermissions_Admin,
Permissions: aclrecordproto2.ACLUserPermissions_Admin,
}
st.userStates[string(root.Identity)] = userState
return
}
func (st *ACLState) saveReadKeyFromRoot(root *aclrecordproto.ACLRoot) (err error) {
func (st *ACLState) saveReadKeyFromRoot(root *aclrecordproto2.ACLRoot) (err error) {
var readKey *symmetric.Key
if len(root.GetDerivationScheme()) != 0 {
var encPubKey []byte
@ -175,7 +175,7 @@ func (st *ACLState) saveReadKeyFromRoot(root *aclrecordproto.ACLRoot) (err error
return
}
readKey, err = aclrecordproto.ACLReadKeyDerive([]byte(st.identity), encPubKey)
readKey, err = aclrecordproto2.ACLReadKeyDerive([]byte(st.identity), encPubKey)
if err != nil {
return
}
@ -199,7 +199,7 @@ func (st *ACLState) saveReadKeyFromRoot(root *aclrecordproto.ACLRoot) (err error
return
}
func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uint64, identity []byte) (err error) {
func (st *ACLState) applyChangeData(changeData *aclrecordproto2.ACLData, hash uint64, identity []byte) (err error) {
defer func() {
if err != nil {
return
@ -214,7 +214,7 @@ func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uin
return
}
if !st.hasPermission(identity, aclrecordproto.ACLUserPermissions_Admin) {
if !st.hasPermission(identity, aclrecordproto2.ACLUserPermissions_Admin) {
err = fmt.Errorf("user %s must have admin permissions", identity)
return
}
@ -230,7 +230,7 @@ func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uin
return nil
}
func (st *ACLState) applyChangeContent(ch *aclrecordproto.ACLContentValue) error {
func (st *ACLState) applyChangeContent(ch *aclrecordproto2.ACLContentValue) error {
switch {
case ch.GetUserPermissionChange() != nil:
return st.applyUserPermissionChange(ch.GetUserPermissionChange())
@ -247,7 +247,7 @@ func (st *ACLState) applyChangeContent(ch *aclrecordproto.ACLContentValue) error
}
}
func (st *ACLState) applyUserPermissionChange(ch *aclrecordproto.ACLUserPermissionChange) error {
func (st *ACLState) applyUserPermissionChange(ch *aclrecordproto2.ACLUserPermissionChange) error {
chIdentity := string(ch.Identity)
state, exists := st.userStates[chIdentity]
if !exists {
@ -258,12 +258,12 @@ func (st *ACLState) applyUserPermissionChange(ch *aclrecordproto.ACLUserPermissi
return nil
}
func (st *ACLState) applyUserInvite(ch *aclrecordproto.ACLUserInvite) error {
func (st *ACLState) applyUserInvite(ch *aclrecordproto2.ACLUserInvite) error {
st.userInvites[ch.InviteId] = ch
return nil
}
func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error {
func (st *ACLState) applyUserJoin(ch *aclrecordproto2.ACLUserJoin) error {
invite, exists := st.userInvites[ch.InviteId]
if !exists {
return fmt.Errorf("no such invite with id %s", ch.InviteId)
@ -276,12 +276,12 @@ func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error {
// validating signature
signature := ch.GetAcceptSignature()
verificationKey, err := signingkey.NewSigningEd25519PubKeyFromBytes(invite.AcceptPublicKey)
verificationKey, err := signingkey2.NewSigningEd25519PubKeyFromBytes(invite.AcceptPublicKey)
if err != nil {
return fmt.Errorf("public key verifying invite accepts is given in incorrect format: %v", err)
}
res, err := verificationKey.(signingkey.PubKey).Verify(ch.Identity, signature)
res, err := verificationKey.(signingkey2.PubKey).Verify(ch.Identity, signature)
if err != nil {
return fmt.Errorf("verification returned error: %w", err)
}
@ -302,7 +302,7 @@ func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error {
}
// adding user to the list
userState := &aclrecordproto.ACLUserState{
userState := &aclrecordproto2.ACLUserState{
Identity: ch.Identity,
EncryptionKey: ch.EncryptionKey,
Permissions: invite.Permissions,
@ -311,13 +311,13 @@ func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error {
return nil
}
func (st *ACLState) applyUserAdd(ch *aclrecordproto.ACLUserAdd) error {
func (st *ACLState) applyUserAdd(ch *aclrecordproto2.ACLUserAdd) error {
chIdentity := string(ch.Identity)
if _, exists := st.userStates[chIdentity]; exists {
return ErrUserAlreadyExists
}
st.userStates[chIdentity] = &aclrecordproto.ACLUserState{
st.userStates[chIdentity] = &aclrecordproto2.ACLUserState{
Identity: ch.Identity,
EncryptionKey: ch.EncryptionKey,
Permissions: ch.Permissions,
@ -337,7 +337,7 @@ func (st *ACLState) applyUserAdd(ch *aclrecordproto.ACLUserAdd) error {
return nil
}
func (st *ACLState) applyUserRemove(ch *aclrecordproto.ACLUserRemove) error {
func (st *ACLState) applyUserRemove(ch *aclrecordproto2.ACLUserRemove) error {
chIdentity := string(ch.Identity)
if chIdentity == st.identity {
return ErrDocumentForbidden
@ -381,7 +381,7 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e
return key, hasher.Sum64(), nil
}
func (st *ACLState) hasPermission(identity []byte, permission aclrecordproto.ACLUserPermissions) bool {
func (st *ACLState) hasPermission(identity []byte, permission aclrecordproto2.ACLUserPermissions) bool {
state, exists := st.userStates[string(identity)]
if !exists {
return false
@ -390,17 +390,17 @@ func (st *ACLState) hasPermission(identity []byte, permission aclrecordproto.ACL
return state.Permissions == permission
}
func (st *ACLState) isUserJoin(data *aclrecordproto.ACLData) bool {
func (st *ACLState) isUserJoin(data *aclrecordproto2.ACLData) bool {
// if we have a UserJoin, then it should always be the first one applied
return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil
}
func (st *ACLState) isUserAdd(data *aclrecordproto.ACLData, identity []byte) bool {
func (st *ACLState) isUserAdd(data *aclrecordproto2.ACLData, identity []byte) bool {
// if we have a UserAdd, then it should always be the first one applied
userAdd := data.GetAclContent()[0].GetUserAdd()
return data.GetAclContent() != nil && userAdd != nil && bytes.Compare(userAdd.GetIdentity(), identity) == 0
}
func (st *ACLState) GetUserStates() map[string]*aclrecordproto.ACLUserState {
func (st *ACLState) GetUserStates() map[string]*aclrecordproto2.ACLUserState {
return st.userStates
}

View file

@ -1,9 +1,9 @@
package list
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
)
type aclStateBuilder struct {

View file

@ -5,10 +5,10 @@ import (
"context"
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"sync"
)

View file

@ -1,8 +1,8 @@
package list
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/testutils/acllistbuilder"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"

View file

@ -5,10 +5,10 @@
package mock_list
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
list2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
reflect "reflect"
aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
list "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
gomock "github.com/golang/mock/gomock"
)
@ -36,10 +36,10 @@ func (m *MockACLList) EXPECT() *MockACLListMockRecorder {
}
// ACLState mocks base method.
func (m *MockACLList) ACLState() *list.ACLState {
func (m *MockACLList) ACLState() *list2.ACLState {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ACLState")
ret0, _ := ret[0].(*list.ACLState)
ret0, _ := ret[0].(*list2.ACLState)
return ret0
}
@ -64,10 +64,10 @@ func (mr *MockACLListMockRecorder) Close() *gomock.Call {
}
// Get mocks base method.
func (m *MockACLList) Get(arg0 string) (*list.ACLRecord, error) {
func (m *MockACLList) Get(arg0 string) (*list2.ACLRecord, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Get", arg0)
ret0, _ := ret[0].(*list.ACLRecord)
ret0, _ := ret[0].(*list2.ACLRecord)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -79,10 +79,10 @@ func (mr *MockACLListMockRecorder) Get(arg0 interface{}) *gomock.Call {
}
// Head mocks base method.
func (m *MockACLList) Head() *list.ACLRecord {
func (m *MockACLList) Head() *list2.ACLRecord {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Head")
ret0, _ := ret[0].(*list.ACLRecord)
ret0, _ := ret[0].(*list2.ACLRecord)
return ret0
}
@ -122,7 +122,7 @@ func (mr *MockACLListMockRecorder) IsAfter(arg0, arg1 interface{}) *gomock.Call
}
// Iterate mocks base method.
func (m *MockACLList) Iterate(arg0 func(*list.ACLRecord) bool) {
func (m *MockACLList) Iterate(arg0 func(*list2.ACLRecord) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Iterate", arg0)
}
@ -134,7 +134,7 @@ func (mr *MockACLListMockRecorder) Iterate(arg0 interface{}) *gomock.Call {
}
// IterateFrom mocks base method.
func (m *MockACLList) IterateFrom(arg0 string, arg1 func(*list.ACLRecord) bool) {
func (m *MockACLList) IterateFrom(arg0 string, arg1 func(*list2.ACLRecord) bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "IterateFrom", arg0, arg1)
}
@ -182,10 +182,10 @@ func (mr *MockACLListMockRecorder) RUnlock() *gomock.Call {
}
// Records mocks base method.
func (m *MockACLList) Records() []*list.ACLRecord {
func (m *MockACLList) Records() []*list2.ACLRecord {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Records")
ret0, _ := ret[0].([]*list.ACLRecord)
ret0, _ := ret[0].([]*list2.ACLRecord)
return ret0
}

View file

@ -3,8 +3,8 @@ package storage
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"sync"
)

View file

@ -4,7 +4,7 @@ package storage
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
)
var ErrUnknownACLId = errors.New("acl does not exist")

View file

@ -6,10 +6,10 @@ package mock_storage
import (
context "context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
reflect "reflect"
aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
gomock "github.com/golang/mock/gomock"
)

View file

@ -2,7 +2,7 @@ package storage
import (
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
)
var ErrUnknownTreeId = errors.New("tree does not exist")

View file

@ -2,7 +2,7 @@ package storage
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
)
type TreeStorage interface {

View file

@ -1,14 +1,13 @@
package acllistbuilder
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys"
encryptionkey2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
signingkey2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric"
"hash/fnv"
"strings"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
)
type SymKey struct {
@ -17,9 +16,9 @@ type SymKey struct {
}
type YAMLKeychain struct {
SigningKeysByYAMLIdentity map[string]signingkey.PrivKey
SigningKeysByRealIdentity map[string]signingkey.PrivKey
EncryptionKeysByYAMLIdentity map[string]encryptionkey.PrivKey
SigningKeysByYAMLIdentity map[string]signingkey2.PrivKey
SigningKeysByRealIdentity map[string]signingkey2.PrivKey
EncryptionKeysByYAMLIdentity map[string]encryptionkey2.PrivKey
ReadKeysByYAMLIdentity map[string]*SymKey
ReadKeysByHash map[uint64]*SymKey
GeneratedIdentities map[string]string
@ -28,9 +27,9 @@ type YAMLKeychain struct {
func NewKeychain() *YAMLKeychain {
return &YAMLKeychain{
SigningKeysByYAMLIdentity: map[string]signingkey.PrivKey{},
SigningKeysByRealIdentity: map[string]signingkey.PrivKey{},
EncryptionKeysByYAMLIdentity: map[string]encryptionkey.PrivKey{},
SigningKeysByYAMLIdentity: map[string]signingkey2.PrivKey{},
SigningKeysByRealIdentity: map[string]signingkey2.PrivKey{},
EncryptionKeysByYAMLIdentity: map[string]encryptionkey2.PrivKey{},
GeneratedIdentities: map[string]string{},
ReadKeysByYAMLIdentity: map[string]*SymKey{},
ReadKeysByHash: map[uint64]*SymKey{},
@ -57,16 +56,16 @@ func (k *YAMLKeychain) AddEncryptionKey(key *Key) {
return
}
var (
newPrivKey encryptionkey.PrivKey
newPrivKey encryptionkey2.PrivKey
err error
)
if key.Value == "generated" {
newPrivKey, _, err = encryptionkey.GenerateRandomRSAKeyPair(2048)
newPrivKey, _, err = encryptionkey2.GenerateRandomRSAKeyPair(2048)
if err != nil {
panic(err)
}
} else {
newPrivKey, err = keys.DecodeKeyFromString(key.Value, encryptionkey.NewEncryptionRsaPrivKeyFromBytes, nil)
newPrivKey, err = keys.DecodeKeyFromString(key.Value, encryptionkey2.NewEncryptionRsaPrivKeyFromBytes, nil)
if err != nil {
panic(err)
}
@ -79,17 +78,17 @@ func (k *YAMLKeychain) AddSigningKey(key *Key) {
return
}
var (
newPrivKey signingkey.PrivKey
pubKey signingkey.PubKey
newPrivKey signingkey2.PrivKey
pubKey signingkey2.PubKey
err error
)
if key.Value == "generated" {
newPrivKey, pubKey, err = signingkey.GenerateRandomEd25519KeyPair()
newPrivKey, pubKey, err = signingkey2.GenerateRandomEd25519KeyPair()
if err != nil {
panic(err)
}
} else {
newPrivKey, err = keys.DecodeKeyFromString(key.Value, signingkey.NewSigningEd25519PrivKeyFromBytes, nil)
newPrivKey, err = keys.DecodeKeyFromString(key.Value, signingkey2.NewSigningEd25519PrivKeyFromBytes, nil)
if err != nil {
panic(err)
}

View file

@ -3,12 +3,12 @@ package acllistbuilder
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/yamltests"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
aclrecordproto2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/testutils/yamltests"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"hash/fnv"
"io/ioutil"
"path"
@ -20,18 +20,18 @@ import (
type ACLListStorageBuilder struct {
aclList string
records []*aclrecordproto.ACLRecord
rawRecords []*aclrecordproto.RawACLRecordWithId
records []*aclrecordproto2.ACLRecord
rawRecords []*aclrecordproto2.RawACLRecordWithId
indexes map[string]int
keychain *YAMLKeychain
rawRoot *aclrecordproto.RawACLRecordWithId
root *aclrecordproto.ACLRoot
rawRoot *aclrecordproto2.RawACLRecordWithId
root *aclrecordproto2.ACLRoot
id string
}
func NewACLListStorageBuilder(keychain *YAMLKeychain) *ACLListStorageBuilder {
return &ACLListStorageBuilder{
records: make([]*aclrecordproto.ACLRecord, 0),
records: make([]*aclrecordproto2.ACLRecord, 0),
indexes: make(map[string]int),
keychain: keychain,
}
@ -60,7 +60,7 @@ func NewACLListStorageBuilderFromFile(file string) (*ACLListStorageBuilder, erro
return tb, nil
}
func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) *aclrecordproto.RawACLRecordWithId {
func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) *aclrecordproto2.RawACLRecordWithId {
protoMarshalled, err := rec.Marshal()
if err != nil {
panic("should be able to marshal final acl message!")
@ -71,7 +71,7 @@ func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte)
panic("should be able to sign final acl message!")
}
rawRec := &aclrecordproto.RawACLRecord{
rawRec := &aclrecordproto2.RawACLRecord{
Payload: protoMarshalled,
Signature: signature,
}
@ -83,7 +83,7 @@ func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte)
id, _ := cid.NewCIDFromBytes(rawMarshalled)
return &aclrecordproto.RawACLRecordWithId{
return &aclrecordproto2.RawACLRecordWithId{
Payload: rawMarshalled,
Id: id,
}
@ -101,11 +101,11 @@ func (t *ACLListStorageBuilder) SetHead(headId string) error {
panic("SetHead is not implemented")
}
func (t *ACLListStorageBuilder) Root() (*aclrecordproto.RawACLRecordWithId, error) {
func (t *ACLListStorageBuilder) Root() (*aclrecordproto2.RawACLRecordWithId, error) {
return t.rawRoot, nil
}
func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) {
func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclrecordproto2.RawACLRecordWithId, error) {
recIdx, ok := t.indexes[id]
if !ok {
if id == t.rawRoot.Id {
@ -116,7 +116,7 @@ func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*a
return t.rawRecords[recIdx], nil
}
func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error {
func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclrecordproto2.RawACLRecordWithId) error {
panic("implement me")
}
@ -124,7 +124,7 @@ func (t *ACLListStorageBuilder) ID() (string, error) {
return t.id, nil
}
func (t *ACLListStorageBuilder) GetRawRecords() []*aclrecordproto.RawACLRecordWithId {
func (t *ACLListStorageBuilder) GetRawRecords() []*aclrecordproto2.RawACLRecordWithId {
return t.rawRecords
}
@ -149,19 +149,19 @@ func (t *ACLListStorageBuilder) Parse(tree *YMLList) {
}
}
func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclrecordproto.ACLRecord {
func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclrecordproto2.ACLRecord {
k := t.keychain.GetKey(rec.ReadKey).(*SymKey)
var aclChangeContents []*aclrecordproto.ACLContentValue
var aclChangeContents []*aclrecordproto2.ACLContentValue
for _, ch := range rec.AclChanges {
aclChangeContent := t.parseACLChange(ch)
aclChangeContents = append(aclChangeContents, aclChangeContent)
}
data := &aclrecordproto.ACLData{
data := &aclrecordproto2.ACLData{
AclContent: aclChangeContents,
}
bytes, _ := data.Marshal()
return &aclrecordproto.ACLRecord{
return &aclrecordproto2.ACLRecord{
PrevId: prevId,
Identity: []byte(t.keychain.GetIdentity(rec.Identity)),
Data: bytes,
@ -170,7 +170,7 @@ func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclreco
}
}
func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecordproto.ACLContentValue) {
func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecordproto2.ACLContentValue) {
switch {
case ch.UserAdd != nil:
add := ch.UserAdd
@ -178,9 +178,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord
encKey := t.keychain.GetKey(add.EncryptionKey).(encryptionkey.PrivKey)
rawKey, _ := encKey.GetPublic().Raw()
convCh = &aclrecordproto.ACLContentValue{
Value: &aclrecordproto.ACLContentValue_UserAdd{
UserAdd: &aclrecordproto.ACLUserAdd{
convCh = &aclrecordproto2.ACLContentValue{
Value: &aclrecordproto2.ACLContentValue_UserAdd{
UserAdd: &aclrecordproto2.ACLUserAdd{
Identity: []byte(t.keychain.GetIdentity(add.Identity)),
EncryptionKey: rawKey,
EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey),
@ -202,9 +202,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord
panic(err)
}
convCh = &aclrecordproto.ACLContentValue{
Value: &aclrecordproto.ACLContentValue_UserJoin{
UserJoin: &aclrecordproto.ACLUserJoin{
convCh = &aclrecordproto2.ACLContentValue{
Value: &aclrecordproto2.ACLContentValue_UserJoin{
UserJoin: &aclrecordproto2.ACLUserJoin{
Identity: []byte(t.keychain.GetIdentity(join.Identity)),
EncryptionKey: rawKey,
AcceptSignature: signature,
@ -220,9 +220,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord
GetKey(invite.EncryptionKey).(encryptionkey.PrivKey)
rawEncKey, _ := encKey.GetPublic().Raw()
convCh = &aclrecordproto.ACLContentValue{
Value: &aclrecordproto.ACLContentValue_UserInvite{
UserInvite: &aclrecordproto.ACLUserInvite{
convCh = &aclrecordproto2.ACLContentValue{
Value: &aclrecordproto2.ACLContentValue_UserInvite{
UserInvite: &aclrecordproto2.ACLUserInvite{
AcceptPublicKey: rawAcceptKey,
EncryptPublicKey: rawEncKey,
EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey),
@ -234,9 +234,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord
case ch.UserPermissionChange != nil:
permissionChange := ch.UserPermissionChange
convCh = &aclrecordproto.ACLContentValue{
Value: &aclrecordproto.ACLContentValue_UserPermissionChange{
UserPermissionChange: &aclrecordproto.ACLUserPermissionChange{
convCh = &aclrecordproto2.ACLContentValue{
Value: &aclrecordproto2.ACLContentValue_UserPermissionChange{
UserPermissionChange: &aclrecordproto2.ACLUserPermissionChange{
Identity: []byte(t.keychain.GetIdentity(permissionChange.Identity)),
Permissions: t.convertPermission(permissionChange.Permission),
},
@ -247,7 +247,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord
newReadKey := t.keychain.GetKey(remove.NewReadKey).(*SymKey)
var replaces []*aclrecordproto.ACLReadKeyReplace
var replaces []*aclrecordproto2.ACLReadKeyReplace
for _, id := range remove.IdentitiesLeft {
encKey := t.keychain.EncryptionKeysByYAMLIdentity[id]
rawEncKey, _ := encKey.GetPublic().Raw()
@ -255,16 +255,16 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord
if err != nil {
panic(err)
}
replaces = append(replaces, &aclrecordproto.ACLReadKeyReplace{
replaces = append(replaces, &aclrecordproto2.ACLReadKeyReplace{
Identity: []byte(t.keychain.GetIdentity(id)),
EncryptionKey: rawEncKey,
EncryptedReadKey: encReadKey,
})
}
convCh = &aclrecordproto.ACLContentValue{
Value: &aclrecordproto.ACLContentValue_UserRemove{
UserRemove: &aclrecordproto.ACLUserRemove{
convCh = &aclrecordproto2.ACLContentValue{
Value: &aclrecordproto2.ACLContentValue_UserRemove{
UserRemove: &aclrecordproto2.ACLUserRemove{
Identity: []byte(t.keychain.GetIdentity(remove.RemovedIdentity)),
ReadKeyReplaces: replaces,
},
@ -291,20 +291,20 @@ func (t *ACLListStorageBuilder) encryptReadKeys(keys []string, encKey encryption
return
}
func (t *ACLListStorageBuilder) convertPermission(perm string) aclrecordproto.ACLUserPermissions {
func (t *ACLListStorageBuilder) convertPermission(perm string) aclrecordproto2.ACLUserPermissions {
switch perm {
case "admin":
return aclrecordproto.ACLUserPermissions_Admin
return aclrecordproto2.ACLUserPermissions_Admin
case "writer":
return aclrecordproto.ACLUserPermissions_Writer
return aclrecordproto2.ACLUserPermissions_Writer
case "reader":
return aclrecordproto.ACLUserPermissions_Reader
return aclrecordproto2.ACLUserPermissions_Reader
default:
panic(fmt.Sprintf("incorrect permission: %s", perm))
}
}
func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto.ACLRecord, id string) error) (err error) {
func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto2.ACLRecord, id string) error) (err error) {
for i := len(t.records) - 1; i >= 0; i-- {
err = f(t.records[i], t.rawRecords[i].Id)
if err != nil {
@ -317,10 +317,10 @@ func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto.ACLR
func (t *ACLListStorageBuilder) parseRoot(root *Root) {
rawSignKey, _ := t.keychain.SigningKeysByYAMLIdentity[root.Identity].GetPublic().Raw()
rawEncKey, _ := t.keychain.EncryptionKeysByYAMLIdentity[root.Identity].GetPublic().Raw()
readKey, _ := aclrecordproto.ACLReadKeyDerive(rawSignKey, rawEncKey)
readKey, _ := aclrecordproto2.ACLReadKeyDerive(rawSignKey, rawEncKey)
hasher := fnv.New64()
hasher.Write(readKey.Bytes())
t.root = &aclrecordproto.ACLRoot{
t.root = &aclrecordproto2.ACLRoot{
Identity: rawSignKey,
EncryptionKey: rawEncKey,
SpaceId: root.SpaceId,

View file

@ -9,8 +9,7 @@ package acllistbuilder
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
"github.com/gogo/protobuf/proto"
"strings"
"unicode"

View file

@ -2,7 +2,7 @@ package tree
import (
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
)
var (

View file

@ -2,11 +2,11 @@ package tree
import (
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric"
"github.com/gogo/protobuf/proto"
"time"
)

View file

@ -2,15 +2,15 @@ package tree
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
list2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
)
type ObjectTreeValidator interface {
// ValidateFullTree should always be entered while holding a read lock on ACLList
ValidateFullTree(tree *Tree, aclList list.ACLList) error
ValidateFullTree(tree *Tree, aclList list2.ACLList) error
// ValidateNewChanges should always be entered while holding a read lock on ACLList
ValidateNewChanges(tree *Tree, aclList list.ACLList, newChanges []*Change) error
ValidateNewChanges(tree *Tree, aclList list2.ACLList, newChanges []*Change) error
}
type objectTreeValidator struct{}
@ -19,7 +19,7 @@ func newTreeValidator() ObjectTreeValidator {
return &objectTreeValidator{}
}
func (v *objectTreeValidator) ValidateFullTree(tree *Tree, aclList list.ACLList) (err error) {
func (v *objectTreeValidator) ValidateFullTree(tree *Tree, aclList list2.ACLList) (err error) {
tree.Iterate(tree.RootId(), func(c *Change) (isContinue bool) {
err = v.validateChange(tree, aclList, c)
return err == nil
@ -27,7 +27,7 @@ func (v *objectTreeValidator) ValidateFullTree(tree *Tree, aclList list.ACLList)
return err
}
func (v *objectTreeValidator) ValidateNewChanges(tree *Tree, aclList list.ACLList, newChanges []*Change) (err error) {
func (v *objectTreeValidator) ValidateNewChanges(tree *Tree, aclList list2.ACLList, newChanges []*Change) (err error) {
for _, c := range newChanges {
err = v.validateChange(tree, aclList, c)
if err != nil {
@ -37,9 +37,9 @@ func (v *objectTreeValidator) ValidateNewChanges(tree *Tree, aclList list.ACLLis
return
}
func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c *Change) (err error) {
func (v *objectTreeValidator) validateChange(tree *Tree, aclList list2.ACLList, c *Change) (err error) {
var (
perm list.UserPermissionPair
perm list2.UserPermissionPair
state = aclList.ACLState()
)
// checking if the user could write
@ -49,7 +49,7 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c
}
if perm.Permission != aclrecordproto.ACLUserPermissions_Writer && perm.Permission != aclrecordproto.ACLUserPermissions_Admin {
err = list.ErrInsufficientPermissions
err = list2.ErrInsufficientPermissions
return
}

View file

@ -6,11 +6,11 @@ package mock_tree
import (
context "context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
tree2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
reflect "reflect"
storage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
tree "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
gomock "github.com/golang/mock/gomock"
)
@ -38,10 +38,10 @@ func (m *MockObjectTree) EXPECT() *MockObjectTreeMockRecorder {
}
// AddContent mocks base method.
func (m *MockObjectTree) AddContent(arg0 context.Context, arg1 tree.SignableChangeContent) (tree.AddResult, error) {
func (m *MockObjectTree) AddContent(arg0 context.Context, arg1 tree2.SignableChangeContent) (tree2.AddResult, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AddContent", arg0, arg1)
ret0, _ := ret[0].(tree.AddResult)
ret0, _ := ret[0].(tree2.AddResult)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -53,14 +53,14 @@ func (mr *MockObjectTreeMockRecorder) AddContent(arg0, arg1 interface{}) *gomock
}
// AddRawChanges mocks base method.
func (m *MockObjectTree) AddRawChanges(arg0 context.Context, arg1 ...*treechangeproto.RawTreeChangeWithId) (tree.AddResult, error) {
func (m *MockObjectTree) AddRawChanges(arg0 context.Context, arg1 ...*treechangeproto.RawTreeChangeWithId) (tree2.AddResult, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0}
for _, a := range arg1 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "AddRawChanges", varargs...)
ret0, _ := ret[0].(tree.AddResult)
ret0, _ := ret[0].(tree2.AddResult)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -177,7 +177,7 @@ func (mr *MockObjectTreeMockRecorder) ID() *gomock.Call {
}
// Iterate mocks base method.
func (m *MockObjectTree) Iterate(arg0 func([]byte) (interface{}, error), arg1 func(*tree.Change) bool) error {
func (m *MockObjectTree) Iterate(arg0 func([]byte) (interface{}, error), arg1 func(*tree2.Change) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Iterate", arg0, arg1)
ret0, _ := ret[0].(error)
@ -191,7 +191,7 @@ func (mr *MockObjectTreeMockRecorder) Iterate(arg0, arg1 interface{}) *gomock.Ca
}
// IterateFrom mocks base method.
func (m *MockObjectTree) IterateFrom(arg0 string, arg1 func([]byte) (interface{}, error), arg2 func(*tree.Change) bool) error {
func (m *MockObjectTree) IterateFrom(arg0 string, arg1 func([]byte) (interface{}, error), arg2 func(*tree2.Change) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateFrom", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
@ -241,10 +241,10 @@ func (mr *MockObjectTreeMockRecorder) RUnlock() *gomock.Call {
}
// Root mocks base method.
func (m *MockObjectTree) Root() *tree.Change {
func (m *MockObjectTree) Root() *tree2.Change {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Root")
ret0, _ := ret[0].(*tree.Change)
ret0, _ := ret[0].(*tree2.Change)
return ret0
}

View file

@ -4,11 +4,11 @@ package tree
import (
"context"
"errors"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common"
list2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric"
"sync"
)
@ -66,7 +66,7 @@ type objectTree struct {
validator ObjectTreeValidator
rawChangeLoader *rawChangeLoader
treeBuilder *treeBuilder
aclList list.ACLList
aclList list2.ACLList
id string
root *treechangeproto.RawTreeChangeWithId
@ -91,13 +91,13 @@ type objectTreeDeps struct {
treeStorage storage.TreeStorage
validator ObjectTreeValidator
rawChangeLoader *rawChangeLoader
aclList list.ACLList
aclList list2.ACLList
}
func defaultObjectTreeDeps(
rootChange *treechangeproto.RawTreeChangeWithId,
treeStorage storage.TreeStorage,
aclList list.ACLList) objectTreeDeps {
aclList list2.ACLList) objectTreeDeps {
keychain := common.NewKeychain()
changeBuilder := newChangeBuilder(keychain, rootChange)
@ -449,7 +449,7 @@ func (ot *objectTree) IterateFrom(id string, convert ChangeConvertFunc, iterate
}
readKey, exists := ot.keys[c.ReadKeyHash]
if !exists {
err = list.ErrNoReadKey
err = list2.ErrNoReadKey
return false
}

View file

@ -2,10 +2,10 @@ package tree
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/testutils/acllistbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
@ -53,9 +53,9 @@ func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot b
}
}
func (c *mockChangeCreator) createNewTreeStorage(treeId, aclHeadId string) storage.TreeStorage {
func (c *mockChangeCreator) createNewTreeStorage(treeId, aclHeadId string) storage2.TreeStorage {
root := c.createRoot(treeId, aclHeadId)
treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, root, []string{root.Id}, []*treechangeproto.RawTreeChangeWithId{root})
treeStorage, _ := storage2.NewInMemoryTreeStorage(treeId, root, []string{root.Id}, []*treechangeproto.RawTreeChangeWithId{root})
return treeStorage
}
@ -95,7 +95,7 @@ func (m *mockChangeValidator) ValidateFullTree(tree *Tree, aclList list.ACLList)
type testTreeContext struct {
aclList list.ACLList
treeStorage storage.TreeStorage
treeStorage storage2.TreeStorage
changeBuilder *mockChangeBuilder
changeCreator *mockChangeCreator
objTree ObjectTree

View file

@ -1,12 +1,12 @@
package tree
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list"
storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/slice"
"go.uber.org/zap"
"math/rand"
"time"
@ -19,7 +19,7 @@ type ObjectTreeCreatePayload struct {
Identity []byte
}
func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (ObjectTree, error) {
func BuildObjectTree(treeStorage storage2.TreeStorage, aclList list.ACLList) (ObjectTree, error) {
rootChange, err := treeStorage.Root()
if err != nil {
return nil, err
@ -31,14 +31,14 @@ func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (Obj
func CreateDerivedObjectTree(
payload ObjectTreeCreatePayload,
aclList list.ACLList,
createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) {
createStorage storage2.TreeStorageCreatorFunc) (objTree ObjectTree, err error) {
return createObjectTree(payload, 0, nil, aclList, createStorage)
}
func CreateObjectTree(
payload ObjectTreeCreatePayload,
aclList list.ACLList,
createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) {
createStorage storage2.TreeStorageCreatorFunc) (objTree ObjectTree, err error) {
bytes := make([]byte, 32)
_, err = rand.Read(bytes)
if err != nil {
@ -52,7 +52,7 @@ func createObjectTree(
timestamp int64,
seed []byte,
aclList list.ACLList,
createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) {
createStorage storage2.TreeStorageCreatorFunc) (objTree ObjectTree, err error) {
aclList.RLock()
var (
deps = defaultObjectTreeDeps(nil, nil, aclList)
@ -80,7 +80,7 @@ func createObjectTree(
deps.changeBuilder.SetRootRawChange(raw)
// create storage
st, err := createStorage(storage.TreeStorageCreatePayload{
st, err := createStorage(storage2.TreeStorageCreatePayload{
TreeId: raw.Id,
RootRawChange: raw,
Changes: []*treechangeproto.RawTreeChangeWithId{raw},

View file

@ -2,8 +2,8 @@ package tree
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
"time"
)

Some files were not shown because too many files have changed in this diff Show more