-
Notifications
You must be signed in to change notification settings - Fork 202
/
utils.go
31 lines (25 loc) · 886 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package testscommon
import (
"fmt"
"time"
"github.com/ElrondNetwork/elrond-go/storage"
"github.com/ElrondNetwork/elrond-go/storage/memorydb"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
)
// HashSize holds the size of a typical hash used by the protocol
const HashSize = 32
// AddTimestampSuffix -
func AddTimestampSuffix(tag string) string {
timestamp := time.Now().Format("20060102150405")
return fmt.Sprintf("%s_%s", tag, timestamp)
}
// CreateMemUnit creates a new in-memory storage unit
func CreateMemUnit() storage.Storer {
capacity := uint32(10)
shards := uint32(1)
sizeInBytes := uint64(0)
cache, _ := storageUnit.NewCache(storageUnit.CacheConfig{Type: storageUnit.LRUCache, Capacity: capacity, Shards: shards, SizeInBytes: sizeInBytes})
persist, _ := memorydb.NewlruDB(100000)
unit, _ := storageUnit.NewStorageUnit(cache, persist)
return unit
}