From 6df3d5393ab4340cbc2bfb278c0c6cee0880fa5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 6 Mar 2014 12:09:28 +0200 Subject: [PATCH] Oops, forgot to update these. Commit fix. --- config/config_test.go | 26 +++++++++++++------------- proto/carrier/heart.go | 13 +++++++------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index cb7bbd3..55ba599 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -98,26 +98,26 @@ func TestPack(t *testing.T) { } } -func TestOverlay(t *testing.T) { +func TestPastry(t *testing.T) { // Ensure pastry space is reduced size (at least issue a warning) - if OverlaySpace != 40 { - t.Errorf("config (overlay): address space is invalid: have %v, want %v.", OverlaySpace, 40) + if PastrySpace != 40 { + t.Errorf("config (overlay): address space is invalid: have %v, want %v.", PastrySpace, 40) } - if size := OverlayResolver().Size() * 8; size < OverlaySpace { - t.Errorf("config (overlay): resolver does not output enough bits for space: have %v, want %v.", size, OverlaySpace) + if size := PastryResolver().Size() * 8; size < PastrySpace { + t.Errorf("config (overlay): resolver does not output enough bits for space: have %v, want %v.", size, PastrySpace) } // Do some sanity checks on the parameters - if OverlayBase < 1 { - t.Errorf("config (overlay): invalid base bits: have %v, want min 1.", OverlayBase) + if PastryBase < 1 { + t.Errorf("config (overlay): invalid base bits: have %v, want min 1.", PastryBase) } - if OverlaySpace%OverlayBase != 0 { - t.Errorf("config (overlay): address space is not divisible into bases: %v %% %v != 0", OverlaySpace, OverlayBase) + if PastrySpace%PastryBase != 0 { + t.Errorf("config (overlay): address space is not divisible into bases: %v %% %v != 0", PastrySpace, PastryBase) } - if OverlayLeaves != 1< 128 { - t.Errorf("config (overlay): strange network buffer size: have %v, want from [16..128].", OverlayNetBuffer) + if PastryNetBuffer < 16 || PastryNetBuffer > 128 { + t.Errorf("config (overlay): strange network buffer size: have %v, want from [16..128].", PastryNetBuffer) } } diff --git a/proto/carrier/heart.go b/proto/carrier/heart.go index 49853fe..81025c1 100644 --- a/proto/carrier/heart.go +++ b/proto/carrier/heart.go @@ -23,9 +23,10 @@ package carrier import ( - "github.com/karalabe/iris/config" "log" "math/big" + + "github.com/karalabe/iris/config" ) // Load report between two carrier nodes. @@ -36,19 +37,19 @@ type report struct { // Adds the node within the topic to the list of monitored entities. func (c *carrier) monitor(topic *big.Int, node *big.Int) error { - id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.OverlaySpace)), node) + id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.PastrySpace)), node) return c.heart.Monitor(id) } // Remove the node of a specific topic from the list of monitored entities. func (c *carrier) unmonitor(topic *big.Int, node *big.Int) error { - id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.OverlaySpace)), node) + id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.PastrySpace)), node) return c.heart.Unmonitor(id) } // Updates the last ping time of a node within a topic. func (c *carrier) ping(topic *big.Int, node *big.Int) error { - id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.OverlaySpace)), node) + id := new(big.Int).Add(new(big.Int).Lsh(topic, uint(config.PastrySpace)), node) return c.heart.Ping(id) } @@ -96,8 +97,8 @@ func (c *carrier) Beat() { // topic member nodes. func (c *carrier) Dead(id *big.Int) { // Split the id into topic and node parts - topic := new(big.Int).Rsh(id, uint(config.OverlaySpace)) - node := new(big.Int).Sub(id, new(big.Int).Lsh(topic, uint(config.OverlaySpace))) + topic := new(big.Int).Rsh(id, uint(config.PastrySpace)) + node := new(big.Int).Sub(id, new(big.Int).Lsh(topic, uint(config.PastrySpace))) // Depending on whether it was the topic parent or a child reown or unsub c.lock.RLock()