<commit_before>package main

import (
	"sort"
	"time"

	"github.com/coreos/etcd/raft/raftpb"

	"github.com/weaveworks/mesh"
)

func membershipLoop(router *mesh.Router, confchangec chan<- raftpb.ConfChange) {
	ticker := time.NewTicker(time.Second)
	defer ticker.Stop()

	var (
		members = membership(router)
		add     []uint64
		rem     []uint64
	)

	for range ticker.C {
		members, add, rem = diff(members, membership(router))
		for _, nodeID := range add {
			confchangec <- raftpb.ConfChange{
				ID:      uint64(router.Ourself.Peer.Name),
				Type:    raftpb.ConfChangeAddNode,
				NodeID:  nodeID,
				Context: []byte{}, // TODO(pb): is this right?
			}
		}
		for _, nodeID := range rem {
			confchangec <- raftpb.ConfChange{
				ID:      uint64(router.Ourself.Peer.Name),
				Type:    raftpb.ConfChangeRemoveNode,
				NodeID:  nodeID,<commit_msg>raft-on-mesh: fix membershipLoop<commit_after>package main

import (
	"sort"
	"time"

	"github.com/coreos/etcd/raft/raftpb"

	"github.com/weaveworks/mesh"
)

func membershipLoop(router *mesh.Router, confchangec chan<- raftpb.ConfChange) {
	ticker := time.NewTicker(time.Second)
	defer ticker.Stop()

	var (
		members = membership(router)
		add     []uint64
		rem     []uint64
	)

	for range ticker.C {
		add, rem, members = diff(members, membership(router))
		for _, nodeID := range add {
			confchangec <- raftpb.ConfChange{
				ID:      uint64(router.Ourself.Peer.Name),
				Type:    raftpb.ConfChangeAddNode,
				NodeID:  nodeID,
				Context: []byte{}, // TODO(pb): is this right?
			}
		}
		for _, nodeID := range rem {
			confchangec <- raftpb.ConfChange{
				ID:      uint64(router.Ourself.Peer.Name),
				Type:    raftpb.ConfChangeRemoveNode,
				NodeID:  nodeID,
{'fraction_non_alphanumeric': 0.13190005810575248, 'fraction_numerical': 0.009296920395119116, 'mean_word_length': 3.2102689486552567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5899416', 'n_tokens_mistral': 715, 'n_tokens_neox': 612, 'n_words': 125}