Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Aug 18, 2024
1 parent dc1029b commit ff121a6
Show file tree
Hide file tree
Showing 13 changed files with 6,745 additions and 6,689 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

*??? ??, ????*

### CHANGES

- Update `pkg/network/anonymity/queue`: deleted key auto generation -> add param pReceiver

<!-- ... -->

## v1.6.18
Expand Down
4,222 changes: 2,111 additions & 2,111 deletions cmd/hidden_lake/_test/result/coverage.out

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cmd/hidden_lake/service/internal/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func testNewNode(dbPath, addr string) anonymity.INode {
}),
asymmetric.LoadRSAPrivKey(testutils.Tc1PrivKey1024),
),
asymmetric.NewRSAPrivKey(testutils.TcKeySize).GetPubKey(),
),
asymmetric.NewListPubKeys(),
)
Expand Down
1 change: 1 addition & 0 deletions cmd/hidden_lake/service/pkg/app/init_anon_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (p *sApp) initAnonNode() error {
FNetworkKey: cfgSettings.GetNetworkKey(),
}),
client,
asymmetric.NewRSAPrivKey(client.GetPrivKey().GetSize()).GetPubKey(),
),
func() asymmetric.IListPubKeys {
f2f := asymmetric.NewListPubKeys()
Expand Down
1 change: 1 addition & 0 deletions pkg/network/anonymity/anonymity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ func testNewNode(timeWait time.Duration, addr string, typeDB, numDB int, f2fDisa
}),
asymmetric.LoadRSAPrivKey(testutils.Tc1PrivKey1024),
),
asymmetric.NewRSAPrivKey(testutils.TcKeySize).GetPubKey(),
),
asymmetric.NewListPubKeys(),
)
Expand Down
1 change: 1 addition & 0 deletions pkg/network/anonymity/examples/echo/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func newNode(serviceName, address string) anonymity.INode {
}),
asymmetric.NewRSAPrivKey(keySize),
),
asymmetric.NewRSAPrivKey(keySize).GetPubKey(),
),
asymmetric.NewListPubKeys(),
)
Expand Down
1 change: 1 addition & 0 deletions pkg/network/anonymity/examples/ping-ping/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func newNode(serviceName, address string) anonymity.INode {
}),
asymmetric.NewRSAPrivKey(keySize),
),
asymmetric.NewRSAPrivKey(keySize).GetPubKey(),
),
asymmetric.NewListPubKeys(),
)
Expand Down
1 change: 1 addition & 0 deletions pkg/network/anonymity/queue/examples/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
}),
asymmetric.NewRSAPrivKey(1024),
),
asymmetric.NewRSAPrivKey(1024).GetPubKey(),
)

ctx, cancel := context.WithCancel(context.Background())
Expand Down
23 changes: 13 additions & 10 deletions pkg/network/anonymity/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ func NewMessageQueueProcessor(
pSettings ISettings,
pVSettings IVSettings,
pClient client.IClient,
pReceiver asymmetric.IPubKey,
) IMessageQueueProcessor {
mq := &sMessageQueueProcessor{
if pSettings.GetQueuePeriod() != 0 {
if pClient.GetPubKey().GetSize() != pReceiver.GetSize() {
panic("pClient.GetPubKey().GetSize() != pReceiver.GetSize()")
}
}
return &sMessageQueueProcessor{
fState: state.NewBoolState(),
fSettings: pSettings,
fVSettings: pVSettings,
Expand All @@ -59,14 +65,11 @@ func NewMessageQueueProcessor(
fQueue: make(chan net_message.IMessage, pSettings.GetMainPoolCapacity()),
fRawQueue: make(chan []byte, pSettings.GetMainPoolCapacity()),
},
}
if pSettings.GetQueuePeriod() != 0 { // if QB=true
mq.fRandPool = &sRandPool{
fRandPool: &sRandPool{
fQueue: make(chan net_message.IMessage, pSettings.GetRandPoolCapacity()),
fReceiver: asymmetric.NewRSAPrivKey(pClient.GetPrivKey().GetSize()).GetPubKey(),
}
fReceiver: pReceiver,
},
}
return mq
}

func (p *sMessageQueueProcessor) GetSettings() ISettings {
Expand Down Expand Up @@ -109,7 +112,7 @@ func (p *sMessageQueueProcessor) Run(pCtx context.Context) error {
func (p *sMessageQueueProcessor) runRandPoolFiller(pCtx context.Context, pWg *sync.WaitGroup, chErr chan<- error) {
defer pWg.Done()

if p.fRandPool == nil {
if p.fSettings.GetQueuePeriod() == 0 { // if QB=false
<-pCtx.Done()
chErr <- pCtx.Err()
return
Expand Down Expand Up @@ -158,7 +161,7 @@ func (p *sMessageQueueProcessor) SetVSettings(pVSettings IVSettings) {
<-p.fMainPool.fQueue
}

if p.fRandPool != nil {
if p.fSettings.GetQueuePeriod() != 0 { // if QB=true
for len(p.fRandPool.fQueue) > 0 {
atomic.AddInt64(&p.fRandPool.fCount, -1)
<-p.fRandPool.fQueue
Expand All @@ -182,7 +185,7 @@ func (p *sMessageQueueProcessor) EnqueueMessage(pPubKey asymmetric.IPubKey, pByt
}

func (p *sMessageQueueProcessor) DequeueMessage(pCtx context.Context) net_message.IMessage {
if p.fRandPool == nil {
if p.fSettings.GetQueuePeriod() == 0 { // if QB=false
select {
case <-pCtx.Done():
return nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/network/anonymity/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestQueueVoidDisabled(t *testing.T) {
}),
asymmetric.LoadRSAPrivKey(testutils.Tc1PrivKey1024),
),
asymmetric.NewRSAPrivKey(testutils.TcKeySize).GetPubKey(),
)

if err := testQueue(queue); err != nil {
Expand Down Expand Up @@ -106,6 +107,7 @@ func TestRunStopQueue(t *testing.T) {
}),
NewVSettings(&SVSettings{}),
client,
asymmetric.NewRSAPrivKey(client.GetPrivKey().GetSize()).GetPubKey(),
)

ctx1, cancel1 := context.WithCancel(context.Background())
Expand Down Expand Up @@ -183,6 +185,7 @@ func TestQueue(t *testing.T) {
}),
asymmetric.LoadRSAPrivKey(testutils.Tc1PrivKey1024),
),
asymmetric.NewRSAPrivKey(testutils.TcKeySize).GetPubKey(),
)

sett := queue.GetSettings()
Expand Down
2 changes: 1 addition & 1 deletion test/result/badge_codelines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ff121a6

Please sign in to comment.