@@ -7,42 +7,41 @@ import (
77
88 "github.com/anyproto/any-sync/commonspace/object/acl/list"
99 "github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
10- "github.com/anyproto/any-sync/consensus/consensusclient"
1110 "github.com/anyproto/any-sync/consensus/consensusproto"
1211 "go.uber.org/atomic"
1312 "go.uber.org/zap"
1413)
1514
16- func newAclObject (ctx context.Context , cs consensusclient. Service , id string ) (* aclObject , error ) {
15+ func ( as * aclService ) newAclObject (ctx context.Context , id string ) (* aclObject , error ) {
1716 obj := & aclObject {
18- id : id ,
19- consService : cs ,
20- ready : make (chan struct {}),
17+ id : id ,
18+ aclService : as ,
19+ ready : make (chan struct {}),
2120 }
22- if err := cs .Watch (id , obj ); err != nil {
21+ if err := as . consService .Watch (id , obj ); err != nil {
2322 return nil , err
2423 }
2524 select {
2625 case <- obj .ready :
2726 if obj .consErr != nil {
28- _ = cs .UnWatch (id )
27+ _ = as . consService .UnWatch (id )
2928 return nil , obj .consErr
3029 }
3130 return obj , nil
3231 case <- ctx .Done ():
33- _ = cs .UnWatch (id )
32+ _ = as . consService .UnWatch (id )
3433 return nil , ctx .Err ()
3534 }
3635}
3736
3837type aclObject struct {
39- id string
40- store liststorage. ListStorage
41- list. AclList
38+ id string
39+ aclService * aclService
40+ store liststorage. ListStorage
4241
43- ready chan struct {}
44- consErr error
45- consService consensusclient. Service
42+ list. AclList
43+ ready chan struct {}
44+ consErr error
4645
4746 lastUsage atomic.Time
4847
@@ -57,7 +56,7 @@ func (a *aclObject) AddConsensusRecords(recs []*consensusproto.RawRecordWithId)
5756 if a .store , a .consErr = liststorage .NewInMemoryAclListStorage (a .id , recs ); a .consErr != nil {
5857 return
5958 }
60- if a .AclList , a .consErr = list .BuildAclList ( a .store , list.NoOpAcceptorVerifier {}); a .consErr != nil {
59+ if a .AclList , a .consErr = list .BuildAclListWithIdentity ( a . aclService . accountService . Account (), a .store , list.NoOpAcceptorVerifier {}); a .consErr != nil {
6160 return
6261 }
6362 } else {
@@ -82,7 +81,7 @@ func (a *aclObject) AddConsensusError(err error) {
8281}
8382
8483func (a * aclObject ) Close () (err error ) {
85- return a .consService .UnWatch (a .id )
84+ return a .aclService . consService .UnWatch (a .id )
8685}
8786
8887func (a * aclObject ) TryClose (objectTTL time.Duration ) (res bool , err error ) {
0 commit comments