Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Oct 14, 2023
1 parent 613c245 commit 7f8f3ad
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ Default config `hlm.cfg`
"erro"
],
"language": "ENG",
"storage_key": "_",
"address": {
"interface": "127.0.0.1:9591",
"incoming": "127.0.0.1:9592"
Expand Down
1 change: 1 addition & 0 deletions cmd/hidden_lake/_default_cfg/docker/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"erro"
],
"language": "ENG",
"storage_key": "_",
"address": {
"interface": ":9591",
"incoming": ":9592"
Expand Down
1 change: 1 addition & 0 deletions cmd/hidden_lake/_default_cfg/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"erro"
],
"language": "ENG",
"storage_key": "_",
"address": {
"interface": "127.0.0.1:9591",
"incoming": "127.0.0.1:9592"
Expand Down
1 change: 1 addition & 0 deletions cmd/hidden_lake/messenger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Default config `hlm.cfg`
"erro"
],
"language": "ENG",
"storage_key": "_",
"address": {
"interface": "127.0.0.1:9591",
"incoming": "127.0.0.1:9592"
Expand Down
5 changes: 3 additions & 2 deletions cmd/hidden_lake/messenger/internal/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func InitConfig(cfgPath string, initCfg *SConfig) (IConfig, error) {
FMessagesCapacity: hlm_settings.CDefaultCapMessages,
FWorkSizeBits: hlm_settings.CDefaultWorkSizeBits,
},
FLogging: []string{logger.CLogInfo, logger.CLogWarn, logger.CLogErro},
FLanguage: hlm_settings.CDefaultLanguage,
FLogging: []string{logger.CLogInfo, logger.CLogWarn, logger.CLogErro},
FStorageKey: hlm_settings.CDefaultStorageKey,
FLanguage: hlm_settings.CDefaultLanguage,
FAddress: &SAddress{
FInterface: hlm_settings.CDefaultInterfaceAddress,
FIncoming: hlm_settings.CDefaultIncomingAddress,
Expand Down
5 changes: 3 additions & 2 deletions cmd/hidden_lake/messenger/pkg/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const (
)

const (
CIamAliasName = "__iam__"
CDefaultLanguage = "ENG"
CIamAliasName = "__iam__"
CDefaultLanguage = "ENG"
CDefaultStorageKey = "_"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions cmd/hidden_lake/traffic/internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type sKeyValueDB struct {
}

func NewKeyValueDB(pSett ISettings) (IKVDatabase, error) {
if pSett.GetCapacity() == 0 {
if pSett.GetMessagesCapacity() == 0 {
return nil, errors.NewError("capacity of messages = 0")
}

Expand Down Expand Up @@ -55,7 +55,7 @@ func (p *sKeyValueDB) Hashes() ([]string, error) {
p.fMutex.Lock()
defer p.fMutex.Unlock()

msgsLimit := p.Settings().GetCapacity()
msgsLimit := p.Settings().GetMessagesCapacity()
res := make([]string, 0, msgsLimit)
for i := uint64(0); i < msgsLimit; i++ {
hash, err := p.fDB.Get(getKeyHash(i))
Expand Down Expand Up @@ -167,7 +167,7 @@ func (p *sKeyValueDB) getPointer() uint64 {
}

func (p *sKeyValueDB) incPointer() error {
msgsLimit := p.Settings().GetCapacity()
msgsLimit := p.Settings().GetMessagesCapacity()
res := encoding.Uint64ToBytes((p.getPointer() + 1) % msgsLimit)
if err := p.fDB.Set(getKeyPointer(), res[:]); err != nil {
return errors.WrapError(err, "set pointer into KV database")
Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/traffic/internal/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func testHmsDefaultInit(dbPath string) error {
FPath: dbPath,
FMessageSizeBytes: testutils.TCMessageSize,
FWorkSizeBits: testutils.TCWorkSize,
FCapacity: testutils.TCCapacity,
FMessagesCapacity: testutils.TCCapacity,
}))
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions cmd/hidden_lake/traffic/internal/database/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ type sSettings struct {
FPath string
FMessageSizeBytes uint64
FWorkSizeBits uint64
FCapacity uint64
FMessagesCapacity uint64
}

func NewSettings(pSett *SSettings) ISettings {
return (&sSettings{
FPath: pSett.FPath,
FWorkSizeBits: pSett.FWorkSizeBits,
FMessageSizeBytes: pSett.FMessageSizeBytes,
FCapacity: pSett.FCapacity,
FMessagesCapacity: pSett.FMessagesCapacity,
}).mustNotNull()
}

Expand All @@ -39,8 +39,8 @@ func (p *sSettings) GetPath() string {
return p.FPath
}

func (s *sSettings) GetCapacity() uint64 {
return s.FCapacity
func (s *sSettings) GetMessagesCapacity() uint64 {
return s.FMessagesCapacity
}

func (p *sSettings) GetMessageSizeBytes() uint64 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/traffic/internal/database/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type IKVDatabase interface {

type ISettings interface {
GetPath() string
GetCapacity() uint64
GetMessagesCapacity() uint64
GetMessageSizeBytes() uint64
GetWorkSizeBits() uint64
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/traffic/internal/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func testAllRun(addr, addrNode string) (*http.Server, conn_keeper.IConnKeeper, d
FPath: fmt.Sprintf(databaseTemplate, addr),
FMessageSizeBytes: testutils.TCMessageSize,
FWorkSizeBits: testutils.TCWorkSize,
FCapacity: testutils.TCCapacity,
FMessagesCapacity: testutils.TCCapacity,
}),
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/traffic/pkg/app/init_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func (p *sApp) initDatabase() error {
sett := database.NewSettings(&database.SSettings{
FPath: fmt.Sprintf("%s/%s", p.fPathTo, hlt_settings.CPathDB),
FCapacity: p.fConfig.GetSettings().GetMessagesCapacity(),
FMessagesCapacity: p.fConfig.GetSettings().GetMessagesCapacity(),
FMessageSizeBytes: p.fConfig.GetSettings().GetMessageSizeBytes(),
FWorkSizeBits: p.fConfig.GetSettings().GetWorkSizeBits(),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"erro"
],
"language": "ENG",
"storage_key": "_",
"address": {
"interface": "messenger-node1:8080",
"incoming": "messenger-node1:8081"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"erro"
],
"language": "ENG",
"storage_key": "_",
"address": {
"interface": "messenger-node2:7070",
"incoming": "messenger-node2:7071"
Expand Down
1 change: 1 addition & 0 deletions examples/anon_messenger/default/node1_hlm/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"warn",
"erro"
],
"storage_key": "_",
"address": {
"interface": "localhost:8080",
"incoming": "localhost:8081"
Expand Down
1 change: 1 addition & 0 deletions examples/anon_messenger/default/node2_hlm/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"warn",
"erro"
],
"storage_key": "_",
"address": {
"interface": "localhost:7070",
"incoming": "localhost:7071"
Expand Down
1 change: 1 addition & 0 deletions examples/anon_messenger/prod_test/node1_hlm/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"warn",
"erro"
],
"storage_key": "_",
"address": {
"interface": "localhost:8080",
"incoming": "localhost:8081"
Expand Down
1 change: 1 addition & 0 deletions examples/anon_messenger/prod_test/node2_hlm/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"warn",
"erro"
],
"storage_key": "_",
"address": {
"interface": "localhost:7070",
"incoming": "localhost:7071"
Expand Down
1 change: 1 addition & 0 deletions examples/anon_messenger/secret_channel/node1_hlm/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"interface": "localhost:8080",
"incoming": "localhost:8081"
},
"storage_key": "_",
"connection": "localhost:8572",
"backup_connections": [
"127.0.0.1:8573"
Expand Down
5 changes: 4 additions & 1 deletion examples/anon_messenger/secret_channel/node1_hlm/hlt.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"settings": {
"message_size_bytes": 8192,
"work_size_bits": 20,
"messages_capacity": 2048,
"work_size_bits": 20
"queue_period_ms": 5000,
"limit_void_size_bytes": 4096
},
"logging": ["info", "warn", "erro"],
"address": {
Expand Down
1 change: 1 addition & 0 deletions examples/anon_messenger/secret_channel/node2_hlm/hlm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"messages_capacity": 2048,
"work_size_bits": 20
},
"storage_key": "_",
"address": {
"interface": "localhost:7070",
"incoming": "localhost:7071"
Expand Down
5 changes: 4 additions & 1 deletion examples/anon_messenger/secret_channel/node2_hlm/hlt.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"settings": {
"message_size_bytes": 8192,
"work_size_bits": 20,
"messages_capacity": 2048,
"work_size_bits": 20
"queue_period_ms": 5000,
"limit_void_size_bytes": 4096
},
"address": {
"http": "localhost:7573"
Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func (p *sSettings) mustNotNull() ISettings {
if p.FWorkSize == 0 {
panic(`p.FWorkSize == 0`)
}
if p.FPassword == "" {
panic(`p.FPassword == ""`)
}
return p
}

Expand Down
11 changes: 9 additions & 2 deletions pkg/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestCryptoStorage(t *testing.T) {
}

func TestSettings(t *testing.T) {
for i := 0; i < 2; i++ {
for i := 0; i < 3; i++ {
testSettings(t, i)
}
}
Expand All @@ -39,10 +39,17 @@ func testSettings(t *testing.T, n int) {
case 0:
_ = NewSettings(&SSettings{
FWorkSize: testutils.TCWorkSize,
FPassword: "CIPHER",
})
case 1:
_ = NewSettings(&SSettings{
FPath: "path",
FPath: "path",
FPassword: "CIPHER",
})
case 2:
_ = NewSettings(&SSettings{
FPath: "path",
FWorkSize: testutils.TCWorkSize,
})
}
}
Expand Down

0 comments on commit 7f8f3ad

Please sign in to comment.