aboutsummaryrefslogtreecommitdiffstats
path: root/whisper
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-13 21:19:34 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-13 21:19:34 +0800
commitcb707ba50ce8626aa1b0e87d7526416a9592852a (patch)
tree5da3164ac4539394c549aa47c3fe79cb60c9c86a /whisper
parent89358d25a4e27194638bfd1c685cc8d88910786e (diff)
downloadgo-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.tar
go-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.tar.gz
go-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.tar.bz2
go-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.tar.lz
go-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.tar.xz
go-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.tar.zst
go-tangerine-cb707ba50ce8626aa1b0e87d7526416a9592852a.zip
whisper: push work in progress for bug report
Diffstat (limited to 'whisper')
-rw-r--r--whisper/whisper.go13
-rw-r--r--whisper/whisper_test.go12
2 files changed, 19 insertions, 6 deletions
diff --git a/whisper/whisper.go b/whisper/whisper.go
index d9affe09b..f3b539d2c 100644
--- a/whisper/whisper.go
+++ b/whisper/whisper.go
@@ -25,17 +25,19 @@ const (
signatureLength = 65
)
+const (
+ DefaultTimeToLive = 50 * time.Second
+ DefaultProofOfWork = 50 * time.Millisecond
+)
+
type MessageEvent struct {
To *ecdsa.PrivateKey
From *ecdsa.PublicKey
Message *Message
}
-const (
- DefaultTimeToLive = 50 * time.Second
- DefaultProofOfWork = 50 * time.Millisecond
-)
-
+// Whisper represents a dark communication interface through the Ethereum
+// network, using its very own P2P communication layer.
type Whisper struct {
protocol p2p.Protocol
filters *filter.Filters
@@ -199,7 +201,6 @@ func (self *Whisper) add(envelope *Envelope) error {
self.expiry[envelope.Expiry].Add(hash)
go self.postEvent(envelope)
}
-
glog.V(logger.Detail).Infof("added whisper envelope %x\n", envelope)
return nil
diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go
index 27c57eee1..5c29956cf 100644
--- a/whisper/whisper_test.go
+++ b/whisper/whisper_test.go
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
)
@@ -17,6 +18,7 @@ type testNode struct {
}
func startNodes(n int) ([]*testNode, error) {
+ // Start up the cluster of nodes
cluster := make([]*testNode, 0, n)
for i := 0; i < n; i++ {
shh := New()
@@ -46,6 +48,11 @@ func startNodes(n int) ([]*testNode, error) {
client: shh,
})
}
+ // Manually wire together the cluster nodes
+ root := cluster[0].server.Self()
+ for _, node := range cluster[1:] {
+ node.server.SuggestPeer(root)
+ }
return cluster, nil
}
@@ -56,6 +63,7 @@ func stopNodes(cluster []*testNode) {
}
func TestSelfMessage(t *testing.T) {
+ // Start the single node cluster
cluster, err := startNodes(1)
if err != nil {
t.Fatalf("failed to boot test cluster: %v", err)
@@ -96,6 +104,10 @@ func TestSelfMessage(t *testing.T) {
}
func TestDirectMessage(t *testing.T) {
+ glog.SetV(6)
+ glog.SetToStderr(true)
+
+ // Start the sender-recipient cluster
cluster, err := startNodes(2)
if err != nil {
t.Fatalf("failed to boot test cluster: %v", err)