aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/envelope.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-04-10 05:49:22 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-10 05:49:22 +0800
commit9cd713551627a9b48e04a77f64a15ea6f829dcf4 (patch)
treef1849e61cd8269dfe9c70861f49216cf78acec3b /whisper/whisperv5/envelope.go
parent8570ef19eb8dfe4e2a450525c589dec291f3a517 (diff)
downloaddexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.gz
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.zst
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.zip
whisper: big refactoring (#13852)
* whisper: GetMessages fixed; size restriction updated * whisper: made PoW and MaxMsgSize customizable * whisper: test added * whisper: sym key management changed * whisper: identity management refactored * whisper: API refactoring (Post and Filter) * whisper: big refactoring complete * whisper: spelling fix * whisper: variable topic size allowed for a filter * whisper: final update * whisper: formatting * whisper: file exchange introduced in wnode * whisper: bugfix * whisper: API updated + new tests * whisper: statistics updated * whisper: wnode server updated * whisper: allowed filtering for variable topic size * whisper: tests added * whisper: resolving merge conflicts * whisper: refactoring (documenting mostly) * whsiper: tests fixed * whisper: down cased error messages * whisper: documenting the API functions * whisper: logging fixed * whisper: fixed wnode parameters * whisper: logs fixed (typos)
Diffstat (limited to 'whisper/whisperv5/envelope.go')
-rw-r--r--whisper/whisperv5/envelope.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/whisper/whisperv5/envelope.go b/whisper/whisperv5/envelope.go
index 5d882d5dc..dffa7b286 100644
--- a/whisper/whisperv5/envelope.go
+++ b/whisper/whisperv5/envelope.go
@@ -21,7 +21,6 @@ package whisperv5
import (
"crypto/ecdsa"
"encoding/binary"
- "errors"
"fmt"
gmath "math"
"math/big"
@@ -83,7 +82,7 @@ func (e *Envelope) isAsymmetric() bool {
}
func (e *Envelope) Ver() uint64 {
- return bytesToIntLittleEndian(e.Version)
+ return bytesToUintLittleEndian(e.Version)
}
// Seal closes the envelope by spending the requested amount of time as a proof
@@ -95,6 +94,9 @@ func (e *Envelope) Seal(options *MessageParams) error {
e.Expiry += options.WorkTime
} else {
target = e.powToFirstBit(options.PoW)
+ if target < 1 {
+ target = 1
+ }
}
buf := make([]byte, 64)
@@ -118,7 +120,7 @@ func (e *Envelope) Seal(options *MessageParams) error {
}
if target > 0 && bestBit < target {
- return errors.New("Failed to reach the PoW target, insufficient work time")
+ return fmt.Errorf("failed to reach the PoW target, specified pow time (%d seconds) was insufficient", options.WorkTime)
}
return nil