forked from TrueCloudLab/frostfs-node
[#428] reputation: Implement local trust storage
Implement in-memory `Storage` which is going to be used to submit the results of interactions with network members. `Storage` also provides an iterator interface, so the component can be used in `Controller`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
29e974df93
commit
f25253738a
2 changed files with 216 additions and 0 deletions
43
pkg/services/reputation/local/storage/storage.go
Normal file
43
pkg/services/reputation/local/storage/storage.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package truststorage
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Prm groups the required parameters of the Storage's constructor.
|
||||
//
|
||||
// All values must comply with the requirements imposed on them.
|
||||
// Passing incorrect parameter values will result in constructor
|
||||
// failure (error or panic depending on the implementation).
|
||||
//
|
||||
// The component is not parameterizable at the moment.
|
||||
type Prm struct{}
|
||||
|
||||
// Storage represents in-memory storage of
|
||||
// local reputation values.
|
||||
//
|
||||
// Storage provides access to normalized local trust
|
||||
// values through iterator interface.
|
||||
//
|
||||
// For correct operation, Storage must be created
|
||||
// using the constructor (New) based on the required parameters
|
||||
// and optional components. After successful creation,
|
||||
// Storage is immediately ready to work through API.
|
||||
type Storage struct {
|
||||
prm Prm
|
||||
|
||||
mtx sync.RWMutex
|
||||
|
||||
mItems map[uint64]*EpochTrustValueStorage
|
||||
}
|
||||
|
||||
// New creates a new instance of the Storage.
|
||||
//
|
||||
// The created Storage does not require additional
|
||||
// initialization and is completely ready for work.
|
||||
func New(prm Prm) *Storage {
|
||||
return &Storage{
|
||||
prm: prm,
|
||||
mItems: make(map[uint64]*EpochTrustValueStorage),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue