mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
whisper: POW updated
This commit is contained in:
parent
74a900ac41
commit
2b549db080
3 changed files with 7 additions and 6 deletions
|
|
@ -55,6 +55,7 @@ const (
|
|||
signatureLength = 65
|
||||
aesKeyLength = 32
|
||||
saltLength = 12
|
||||
AESNonceMaxLength = 12
|
||||
|
||||
MaxMessageLength = 0xFFFF // todo: remove this restriction after testing in morden and analizing stats. this should be regulated by MinimumPoW.
|
||||
MinimumPoW = 10.0 // todo: review
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (e *Envelope) calculatePoW(diff uint32) {
|
|||
h = crypto.Keccak256(buf)
|
||||
firstBit := common.FirstBitSet(common.BigD(h))
|
||||
x := math.Pow(2, float64(firstBit))
|
||||
x /= float64(len(e.Data) + len(e.Salt) + len(e.AESNonce))
|
||||
x /= float64(len(e.Data)) // we only count e.Data, other variable-sized members are checked in Whisper.add()
|
||||
x /= float64(e.TTL + diff)
|
||||
e.pow = x
|
||||
}
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ func (wh *Whisper) add(envelope *Envelope) error {
|
|||
return fmt.Errorf("oversized Version")
|
||||
}
|
||||
|
||||
if len(envelope.AESNonce) > 12 {
|
||||
if len(envelope.AESNonce) > AESNonceMaxLength {
|
||||
// the standard AES GSM nonce size is 12,
|
||||
// but const gcmStandardNonceSize cannot be accessed directly
|
||||
return fmt.Errorf("oversized AESNonce")
|
||||
|
|
|
|||
Loading…
Reference in a new issue