aboutsummaryrefslogtreecommitdiffstats
path: root/whisper
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-16 18:27:38 +0800
committerobscuren <geffobscura@gmail.com>2015-03-16 18:27:38 +0800
commitb5234413611ce5984292f85a01de1f56c045b490 (patch)
treee6e0c6f7fe8358a2dc63cdea11ac66b4f59397f5 /whisper
parent0b8f66ed9ef177dc72442dd7ba337c6733e30344 (diff)
downloaddexon-b5234413611ce5984292f85a01de1f56c045b490.tar
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.gz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.bz2
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.lz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.xz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.zst
dexon-b5234413611ce5984292f85a01de1f56c045b490.zip
Moved ethutil => common
Diffstat (limited to 'whisper')
-rw-r--r--whisper/envelope.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/whisper/envelope.go b/whisper/envelope.go
index d30397c98..577638046 100644
--- a/whisper/envelope.go
+++ b/whisper/envelope.go
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -28,7 +28,7 @@ type Envelope struct {
func (self *Envelope) Hash() Hash {
if self.hash == EmptyHash {
- self.hash = H(crypto.Sha3(ethutil.Encode(self)))
+ self.hash = H(crypto.Sha3(common.Encode(self)))
}
return self.hash
@@ -76,14 +76,14 @@ func (self *Envelope) Open(prv *ecdsa.PrivateKey) (msg *Message, err error) {
func (self *Envelope) proveWork(dura time.Duration) {
var bestBit int
d := make([]byte, 64)
- copy(d[:32], ethutil.Encode(self.withoutNonce()))
+ copy(d[:32], common.Encode(self.withoutNonce()))
then := time.Now().Add(dura).UnixNano()
for n := uint32(0); time.Now().UnixNano() < then; {
for i := 0; i < 1024; i++ {
binary.BigEndian.PutUint32(d[60:], n)
- fbs := ethutil.FirstBitSet(ethutil.BigD(crypto.Sha3(d)))
+ fbs := common.FirstBitSet(common.BigD(crypto.Sha3(d)))
if fbs > bestBit {
bestBit = fbs
self.Nonce = n
@@ -96,17 +96,17 @@ func (self *Envelope) proveWork(dura time.Duration) {
func (self *Envelope) valid() bool {
d := make([]byte, 64)
- copy(d[:32], ethutil.Encode(self.withoutNonce()))
+ copy(d[:32], common.Encode(self.withoutNonce()))
binary.BigEndian.PutUint32(d[60:], self.Nonce)
- return ethutil.FirstBitSet(ethutil.BigD(crypto.Sha3(d))) > 0
+ return common.FirstBitSet(common.BigD(crypto.Sha3(d))) > 0
}
func (self *Envelope) withoutNonce() interface{} {
- return []interface{}{self.Expiry, self.Ttl, ethutil.ByteSliceToInterface(self.Topics), self.Data}
+ return []interface{}{self.Expiry, self.Ttl, common.ByteSliceToInterface(self.Topics), self.Data}
}
func (self *Envelope) RlpData() interface{} {
- return []interface{}{self.Expiry, self.Ttl, ethutil.ByteSliceToInterface(self.Topics), self.Data, self.Nonce}
+ return []interface{}{self.Expiry, self.Ttl, common.ByteSliceToInterface(self.Topics), self.Data, self.Nonce}
}
func (self *Envelope) DecodeRLP(s *rlp.Stream) error {
@@ -128,7 +128,7 @@ func (self *Envelope) DecodeRLP(s *rlp.Stream) error {
self.Nonce = extenv.Nonce
// TODO We should use the stream directly here.
- self.hash = H(crypto.Sha3(ethutil.Encode(self)))
+ self.hash = H(crypto.Sha3(common.Encode(self)))
return nil
}