good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
ccf80835
Commit
ccf80835
authored
7 years ago
by
Vlad Gluhovsky
Committed by
Péter Szilágyi
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
whisper: Seal function fixed (#16048)
parent
c4712bf9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
whisper/whisperv6/envelope.go
+14
-6
14 additions, 6 deletions
whisper/whisperv6/envelope.go
with
14 additions
and
6 deletions
whisper/whisperv6/envelope.go
+
14
−
6
View file @
ccf80835
...
...
@@ -77,15 +77,19 @@ func NewEnvelope(ttl uint32, topic TopicType, msg *sentMessage) *Envelope {
// Seal closes the envelope by spending the requested amount of time as a proof
// of work on hashing the data.
func
(
e
*
Envelope
)
Seal
(
options
*
MessageParams
)
error
{
var
target
,
bestBit
int
if
options
.
PoW
==
0
{
// adjust for the duration of Seal() execution only if execution time is predefined unconditionally
// PoW is not required
return
nil
}
var
target
,
bestBit
int
if
options
.
PoW
<
0
{
// target is not set - the function should run for a period
// of time specified in WorkTime param. Since we can predict
// the execution time, we can also adjust Expiry.
e
.
Expiry
+=
options
.
WorkTime
}
else
{
target
=
e
.
powToFirstBit
(
options
.
PoW
)
if
target
<
1
{
target
=
1
}
}
buf
:=
make
([]
byte
,
64
)
...
...
@@ -143,7 +147,11 @@ func (e *Envelope) powToFirstBit(pow float64) int {
x
*=
float64
(
e
.
TTL
)
bits
:=
gmath
.
Log2
(
x
)
bits
=
gmath
.
Ceil
(
bits
)
return
int
(
bits
)
res
:=
int
(
bits
)
if
res
<
1
{
res
=
1
}
return
res
}
// Hash returns the SHA3 hash of the envelope, calculating it if not yet done.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment