lbcd/claimtrie/temporal/temporalrepo/memory.go
Roy Lee 6828cf5e36 [lbry] claimtrie: import current snapshot
Sync to tip

Co-authored-by: Brannon King <countprimes@gmail.com>
2022-05-23 23:53:30 -07:00

45 lines
722 B
Go

package temporalrepo
type Memory struct {
cache map[int32]map[string]bool
}
func NewMemory() *Memory {
return &Memory{
cache: map[int32]map[string]bool{},
}
}
func (repo *Memory) SetNodesAt(names [][]byte, heights []int32) error {
for i, height := range heights {
c, ok := repo.cache[height]
if !ok {
c = map[string]bool{}
repo.cache[height] = c
}
name := string(names[i])
c[name] = true
}
return nil
}
func (repo *Memory) NodesAt(height int32) ([][]byte, error) {
var names [][]byte
for name := range repo.cache[height] {
names = append(names, []byte(name))
}
return names, nil
}
func (repo *Memory) Close() error {
return nil
}
func (repo *Memory) Flush() error {
return nil
}