-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: Read placement policies from contract
Closes #999. Signed-off-by: Evgenii Baidakov <[email protected]>
- Loading branch information
Showing
9 changed files
with
268 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/util" | ||
"github.com/nspcc-dev/neofs-sdk-go/netmap" | ||
) | ||
|
||
type ( | ||
storagePolicyService struct { | ||
mu *sync.RWMutex | ||
provider servicePolicyProvider | ||
} | ||
|
||
servicePolicyProvider interface { | ||
GetPlacementPolicy(userAddr util.Uint160, policyName string) (*netmap.PlacementPolicy, error) | ||
} | ||
) | ||
|
||
func newStoragePolicyService(provider servicePolicyProvider) *storagePolicyService { | ||
return &storagePolicyService{ | ||
provider: provider, | ||
mu: &sync.RWMutex{}, | ||
} | ||
} | ||
|
||
func (s *storagePolicyService) GetPlacementPolicy(userAddr util.Uint160, policyName string) (*netmap.PlacementPolicy, error) { | ||
s.mu.RLock() | ||
defer s.mu.RUnlock() | ||
|
||
return s.provider.GetPlacementPolicy(userAddr, policyName) | ||
} | ||
|
||
func (s *storagePolicyService) UpdateProvider(p servicePolicyProvider) { | ||
s.mu.Lock() | ||
s.provider = p | ||
s.mu.Unlock() | ||
} |
Oops, something went wrong.