Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
ccf80835
Commit
ccf80835
authored
Feb 09, 2018
by
gluk256
Committed by
Péter Szilágyi
Feb 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: Seal function fixed (#16048)
parent
c4712bf9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
envelope.go
whisper/whisperv6/envelope.go
+14
-6
No files found.
whisper/whisperv6/envelope.go
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment