Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Oct 7, 2024
1 parent e4f54d5 commit d68f5e1
Show file tree
Hide file tree
Showing 29 changed files with 7,868 additions and 9,853 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Update `cmd/hidden_lake/helpers/traffic`: "messages_capacity" can be = 0
- Update `pkg/storage/cache`: cache/lru/lru.go -> cache/lru.go
- Update `internal/api`: Request success if "200 >= code < 300" (old version only code=200)
- Update `pkg/storage/database`: delete encryption

<!-- ... -->

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ The `go-peer` library contains a large number of functions necessary to ensure t
3. The `network` module is a decentralized communication between network nodes. Allows you to delimit networks and give information a random appearance using the network key.
4. The `network/anonymity` module to ensure anonymity based on the fifth^ stage. Presents the main functions for working with the network on top of the `network` and `network/anonymity/queue` modules.
5. The `network/anonymity/queue` module represents the generation, storage and issuance of encrypted messages every time the period specified by the application is reached. Uses the `client`, `client/message` and `network/message` modules.
6. The `storage/database` module is a `key-value` database with the functions of value encryption and key hashing.

> Examples of works in the directories [pkg/client/examples](pkg/client/examples/), [pkg/network/examples](pkg/network/examples/), [pkg/network/anonymity/examples](pkg/network/anonymity/examples/), [pkg/network/anonymity/queue/examples](pkg/network/anonymity/queue/examples/);
Expand Down
8,777 changes: 4,351 additions & 4,426 deletions cmd/hidden_lake/_test/result/coverage.out

Large diffs are not rendered by default.

603 changes: 298 additions & 305 deletions cmd/hidden_lake/_test/result/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions cmd/hidden_lake/adapters/common/cmd/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ var (

func initDB() database.IKVDatabase {
var err error
db, err = database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: databasePath,
}),
)
db, err = database.NewKVDatabase(databasePath)
if err != nil {
panic(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ func (p *sApp) Run(pCtx context.Context) error {
}
defer func() { _ = p.fState.Disable(nil) }()

kvDB, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: settings.CPathDB,
}),
)
kvDB, err := database.NewKVDatabase(settings.CPathDB)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type sKeyValueDB struct {
fDB database.IKVDatabase
}

func NewKeyValueDB(pSettings database.ISettings) (IKVDatabase, error) {
db, err := database.NewKVDatabase(pSettings)
func NewKeyValueDB(pPath string) (IKVDatabase, error) {
db, err := database.NewKVDatabase(pPath)
if err != nil {
return nil, utils.MergeErrors(ErrCreateDB, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/number571/go-peer/pkg/crypto/asymmetric"
"github.com/number571/go-peer/pkg/storage/database"
testutils "github.com/number571/go-peer/test/utils"
)

Expand All @@ -31,9 +30,7 @@ func TestDatabase(t *testing.T) {
os.RemoveAll(tcPath)
defer os.RemoveAll(tcPath)

db, err := NewKeyValueDB(database.NewSettings(&database.SSettings{
FPath: tcPath,
}))
db, err := NewKeyValueDB(tcPath)
if err != nil {
t.Error(err)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ import (

hlm_database "github.com/number571/go-peer/cmd/hidden_lake/applications/messenger/internal/database"
hlm_settings "github.com/number571/go-peer/cmd/hidden_lake/applications/messenger/pkg/settings"
"github.com/number571/go-peer/pkg/storage/database"
)

func (p *sApp) initDatabase() error {
db, err := hlm_database.NewKeyValueDB(
database.NewSettings(&database.SSettings{
FPath: filepath.Join(p.fPathTo, hlm_settings.CPathDB),
}),
)
db, err := hlm_database.NewKeyValueDB(filepath.Join(p.fPathTo, hlm_settings.CPathDB))
if err != nil {
return fmt.Errorf("open KV database: %w", err)
}
Expand Down
13 changes: 0 additions & 13 deletions cmd/hidden_lake/helpers/traffic/internal/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,4 @@ func TestVoidKVDatabase(t *testing.T) {
t.Error(err)
return
}
sett := db.GetSettings()
if sett.GetPassword() != "" {
t.Error("password is not null")
return
}
if sett.GetWorkSize() != 0 {
t.Error("work size is not null")
return
}
if sett.GetPath() != "_" {
t.Error("path is not null")
return
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import "github.com/number571/go-peer/pkg/storage/database"

var _ database.IKVDatabase = &sVoidKVDatabase{}

type sVoidKVDatabase struct{ fSettings database.ISettings }
type sVoidKVDatabase struct{}

func NewVoidKVDatabase() database.IKVDatabase {
return &sVoidKVDatabase{fSettings: database.NewSettings(&database.SSettings{FPath: "_"})}
return &sVoidKVDatabase{}
}

func (p *sVoidKVDatabase) Set([]byte, []byte) error { return nil }
func (p *sVoidKVDatabase) Get([]byte) ([]byte, error) { return nil, database.ErrNotFound }
func (p *sVoidKVDatabase) Del([]byte) error { return nil }
func (p *sVoidKVDatabase) Close() error { return nil }
func (p *sVoidKVDatabase) GetSettings() database.ISettings { return p.fSettings }
func (p *sVoidKVDatabase) Set([]byte, []byte) error { return nil }
func (p *sVoidKVDatabase) Get([]byte) ([]byte, error) { return nil, database.ErrNotFound }
func (p *sVoidKVDatabase) Del([]byte) error { return nil }
func (p *sVoidKVDatabase) Close() error { return nil }
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ func testNetworkMessageSettings() net_message.IConstructSettings {
}

func testAllRun(addr string) (*http.Server, context.CancelFunc, storage.IMessageStorage, hlt_client.IClient) {
db, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: fmt.Sprintf(databaseTemplate, addr),
}),
)
db, err := database.NewKVDatabase(fmt.Sprintf(databaseTemplate, addr))
if err != nil {
panic(err)
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/hidden_lake/helpers/traffic/pkg/app/init_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ func (p *sApp) initDatabase() error {
p.fDatabase = hlt_database.NewVoidKVDatabase()
return nil
}
db, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: filepath.Join(p.fPathTo, hlt_settings.CPathDB),
}),
)
db, err := database.NewKVDatabase(filepath.Join(p.fPathTo, hlt_settings.CPathDB))
if err != nil {
return fmt.Errorf("init database: %w", err)
}
Expand Down
8 changes: 1 addition & 7 deletions cmd/hidden_lake/service/internal/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ func testRunNewNode(dbPath, addr string) (anonymity.INode, context.Context, cont
}

func testNewNode(dbPath, addr string) anonymity.INode {
db, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: dbPath,
FWorkSize: testutils.TCWorkSize,
FPassword: "CIPHER",
}),
)
db, err := database.NewKVDatabase(dbPath)
if err != nil {
panic(err)
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/hidden_lake/service/pkg/app/init_anon_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ func (p *sApp) initAnonNode() error {
cfgSettings = cfg.GetSettings()
)

kvDatabase, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: filepath.Join(p.fPathTo, hls_settings.CPathDB),
}),
)
kvDatabase, err := database.NewKVDatabase(filepath.Join(p.fPathTo, hls_settings.CPathDB))
if err != nil {
return utils.MergeErrors(ErrOpenKVDatabase, err)
}
Expand Down
8 changes: 1 addition & 7 deletions pkg/network/anonymity/anonymity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,7 @@ func (p *stLogging) HasErro() bool {
*/

func testNewNode(timeWait time.Duration, addr string, typeDB, numDB int) (INode, context.CancelFunc) {
db, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: fmt.Sprintf(tcPathDBTemplate, typeDB, numDB),
FWorkSize: testutils.TCWorkSize,
FPassword: "CIPHER",
}),
)
db, err := database.NewKVDatabase(fmt.Sprintf(tcPathDBTemplate, typeDB, numDB))
if err != nil {
panic(err)
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/network/anonymity/examples/echo/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ func newNode(serviceName, address string) anonymity.INode {
},
),
func() database.IKVDatabase {
db, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: "./database_" + serviceName + ".db",
}),
)
db, err := database.NewKVDatabase("./database_" + serviceName + ".db")
if err != nil {
panic(err)
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/network/anonymity/examples/ping-ping/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ func newNode(serviceName, address string) anonymity.INode {
},
),
func() database.IKVDatabase {
db, err := database.NewKVDatabase(
database.NewSettings(&database.SSettings{
FPath: "./database_" + serviceName + ".db",
}),
)
db, err := database.NewKVDatabase("./database_" + serviceName + ".db")
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type INode interface {

GetSettings() ISettings
GetCacheSetter() cache.ICacheSetter
GetConnections() map[string]conn.IConn

GetConnections() map[string]conn.IConn
AddConnection(context.Context, string) error
DelConnection(string) error

Expand Down
Loading

0 comments on commit d68f5e1

Please sign in to comment.