aboutsummaryrefslogtreecommitdiffstats
path: root/whisper
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-14 20:16:02 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-14 20:16:02 +0800
commitf6efdd8aad96db24f29268b4393e95644dbbd18a (patch)
tree74d85a83763f5e20f3f036e9b7ca19711be5770d /whisper
parent1a4cfc173eb3f62c5859d25744f3c0de119e1b59 (diff)
downloadgo-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.tar
go-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.tar.gz
go-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.tar.bz2
go-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.tar.lz
go-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.tar.xz
go-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.tar.zst
go-tangerine-f6efdd8aad96db24f29268b4393e95644dbbd18a.zip
whisper: shorten constants to TTL and PoW
Diffstat (limited to 'whisper')
-rw-r--r--whisper/main.go4
-rw-r--r--whisper/message.go2
-rw-r--r--whisper/message_test.go8
-rw-r--r--whisper/whisper.go4
-rw-r--r--whisper/whisper_test.go12
5 files changed, 15 insertions, 15 deletions
diff --git a/whisper/main.go b/whisper/main.go
index 422f0fa3b..3c8c3801f 100644
--- a/whisper/main.go
+++ b/whisper/main.go
@@ -69,10 +69,10 @@ func selfSend(shh *whisper.Whisper, payload []byte) error {
})
// Wrap the payload and encrypt it
msg := whisper.NewMessage(payload)
- envelope, err := msg.Wrap(whisper.DefaultProofOfWork, whisper.Options{
+ envelope, err := msg.Wrap(whisper.DefaultPoW, whisper.Options{
From: id,
To: &id.PublicKey,
- TTL: whisper.DefaultTimeToLive,
+ TTL: whisper.DefaultTTL,
})
if err != nil {
return fmt.Errorf("failed to seal message: %v", err)
diff --git a/whisper/message.go b/whisper/message.go
index a4de18f65..0513627b4 100644
--- a/whisper/message.go
+++ b/whisper/message.go
@@ -62,7 +62,7 @@ func NewMessage(payload []byte) *Message {
func (self *Message) Wrap(pow time.Duration, options Options) (*Envelope, error) {
// Use the default TTL if non was specified
if options.TTL == 0 {
- options.TTL = DefaultTimeToLive
+ options.TTL = DefaultTTL
}
// Sign and encrypt the message if requested
if options.From != nil {
diff --git a/whisper/message_test.go b/whisper/message_test.go
index 319bc6025..18a254e5c 100644
--- a/whisper/message_test.go
+++ b/whisper/message_test.go
@@ -13,7 +13,7 @@ func TestMessageSimpleWrap(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- if _, err := msg.Wrap(DefaultProofOfWork, Options{}); err != nil {
+ if _, err := msg.Wrap(DefaultPoW, Options{}); err != nil {
t.Fatalf("failed to wrap message: %v", err)
}
if msg.Flags&signatureFlag != 0 {
@@ -36,7 +36,7 @@ func TestMessageCleartextSignRecover(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- if _, err := msg.Wrap(DefaultProofOfWork, Options{
+ if _, err := msg.Wrap(DefaultPoW, Options{
From: key,
}); err != nil {
t.Fatalf("failed to sign message: %v", err)
@@ -69,7 +69,7 @@ func TestMessageAnonymousEncryptDecrypt(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
To: &key.PublicKey,
})
if err != nil {
@@ -104,7 +104,7 @@ func TestMessageFullCrypto(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
From: fromKey,
To: &toKey.PublicKey,
})
diff --git a/whisper/whisper.go b/whisper/whisper.go
index 2634a23a4..b83e3f1c6 100644
--- a/whisper/whisper.go
+++ b/whisper/whisper.go
@@ -30,8 +30,8 @@ const (
)
const (
- DefaultTimeToLive = 50 * time.Second
- DefaultProofOfWork = 50 * time.Millisecond
+ DefaultTTL = 50 * time.Second
+ DefaultPoW = 50 * time.Millisecond
)
type MessageEvent struct {
diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go
index 3f903a9dc..97644fd27 100644
--- a/whisper/whisper_test.go
+++ b/whisper/whisper_test.go
@@ -83,10 +83,10 @@ func TestSelfMessage(t *testing.T) {
})
// Send a dummy message to oneself
msg := NewMessage([]byte("self whisper"))
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
From: self,
To: &self.PublicKey,
- TTL: DefaultTimeToLive,
+ TTL: DefaultTTL,
})
if err != nil {
t.Fatalf("failed to wrap message: %v", err)
@@ -126,10 +126,10 @@ func TestDirectMessage(t *testing.T) {
})
// Send a dummy message from the sender
msg := NewMessage([]byte("direct whisper"))
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
From: senderId,
To: &recipientId.PublicKey,
- TTL: DefaultTimeToLive,
+ TTL: DefaultTTL,
})
if err != nil {
t.Fatalf("failed to wrap message: %v", err)
@@ -184,9 +184,9 @@ func testBroadcast(anonymous bool, t *testing.T) {
}
// Send a dummy message from the sender
msg := NewMessage([]byte("broadcast whisper"))
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
Topics: NewTopicsFromStrings("broadcast topic"),
- TTL: DefaultTimeToLive,
+ TTL: DefaultTTL,
})
if err != nil {
t.Fatalf("failed to wrap message: %v", err)