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)
This commit is contained in:
gluk256
2017-04-09 23:49:22 +02:00
committed by Felix Lange
parent 8570ef19eb
commit 9cd7135516
14 changed files with 1398 additions and 731 deletions

View File

@@ -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