diff --git a/cluster/delegate.go b/cluster/delegate.go index 3e73267..d8d632d 100644 --- a/cluster/delegate.go +++ b/cluster/delegate.go @@ -20,7 +20,7 @@ func (n *delegateNode) NotifyConflict(node, other *memberlist.Node) { // Metadata is provided by the local node settings, encoding is handled // by the node implementation directly func (n *delegateNode) NodeMeta(limit int) []byte { - encoded, err := n.Encode(limit) + encoded, err := n.EncodeMeta(limit) if err != nil { logrus.Errorf("failed to encode local node: %s", err) return nil diff --git a/common/node.go b/common/node.go index 4babcc2..b2e8f2b 100644 --- a/common/node.go +++ b/common/node.go @@ -26,8 +26,8 @@ func (n *Node) String() string { return n.Addr.String() } -// Encode the node metadata to bytes, in a deterministic reversible way -func (n *Node) Encode(limit int) ([]byte, error) { +// EncodeMeta the node metadata to bytes, in a deterministic reversible way +func (n *Node) EncodeMeta(limit int) ([]byte, error) { buf := &bytes.Buffer{} if err := gob.NewEncoder(buf).Encode(n.nodeMeta); err != nil { return nil, errors.Wrap(err, "could not encode local state") @@ -38,8 +38,8 @@ func (n *Node) Encode(limit int) ([]byte, error) { return buf.Bytes(), nil } -// Decode the node Meta field into its metadata -func (n *Node) Decode() error { +// DecodeMeta the node Meta field into its metadata +func (n *Node) DecodeMeta() error { // TODO: we blindly trust the info we get from the peers; We should be more defensive to limit the damage a leaked // PSK can cause. nm := nodeMeta{} diff --git a/common/node_test.go b/common/node_test.go index 240677f..0d66af8 100644 --- a/common/node_test.go +++ b/common/node_test.go @@ -18,9 +18,9 @@ func Test_Node_Encode_Decode(t *testing.T) { PubKey: pubKey, }, } - encoded, _ := node.Encode(1024) + encoded, _ := node.EncodeMeta(1024) new := Node{Meta: encoded} - new.Decode() + new.DecodeMeta() if !reflect.DeepEqual(node.nodeMeta, new.nodeMeta) { t.Errorf("node encoding then decoding mismatch: %s / %s", node.nodeMeta, new.nodeMeta) } diff --git a/main.go b/main.go index 2a1655a..f15fc95 100644 --- a/main.go +++ b/main.go @@ -80,7 +80,7 @@ func main() { hosts := make(map[string][]string, len(rawNodes)) logrus.Info("cluster members:\n") for _, node := range rawNodes { - if err := node.Decode(); err != nil { + if err := node.DecodeMeta(); err != nil { logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr) continue }