func (a *MemoryAcceptor) Accept(ctx context.Context, key string, age Age, b Ballot, value []byte) (err error) {
	defer func() {
		level.Debug(a.logger).Log(
			"method", "Accept", "key", key, "age", age, "B", b,
			"success", err == nil, "err", err,
		)
	}()
	a.mtx.Lock()
	defer a.mtx.Unlock()
	if incoming, existing := age, a.ages[age.ID]; incoming.youngerThan(existing) {
		return AgeError{Incoming: incoming, Existing: existing}
	}
	av := a.values[key]
	if av.promise.greaterThan(b) {
		return ConflictError{Proposed: b, Existing: av.promise, ExistingKind: "promise"}
	}
	if av.accepted.greaterThan(b) {
		return ConflictError{Proposed: b, Existing: av.accepted, ExistingKind: "accepted"}
	}
	av.promise, av.accepted, av.value = zeroballot, b, value
	a.values[key] = av
	a.watchers.broadcast(key, value)
	return nil
}
Accept implements the second-phase responsibilities of an acceptor.
package protocol
import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"sync"
	"github.com/go-kit/kit/log"
	"github.com/go-kit/kit/log/level"
)
var ErrNotEqual = errors.New("not equal")
type MemoryAcceptor struct {
	mtx      sync.Mutex
	addr     string
	ages     map[string]Age
	values   map[string]acceptedValue
	watchers watchers
	logger   log.Logger
}
type acceptedValue struct {
	promise  Ballot
	accepted Ballot
	value    []byte
}
var zeroballot Ballot
func NewMemoryAcceptor(addr string, logger log.Logger) *MemoryAcceptor {
	return &MemoryAcceptor{
		addr:     addr,
		ages:     map[string]Age{},
		values:   map[string]acceptedValue{},
		watchers: watchers{},
		logger:   logger,
	}
}
func (a *MemoryAcceptor) Address() string {
	return a.addr
}
func (a *MemoryAcceptor) Prepare(ctx context.Context, key string, age Age, b Ballot) (value []byte, current Ballot, err error) {
	defer func() {
		level.Debug(a.logger).Log(
			"method", "Prepare", "key", key, "age", age, "B", b,
			"success", err == nil, "return_ballot", current, "err", err,
		)
	}()
	a.mtx.Lock()
	defer a.mtx.Unlock()
	if incoming, existing := age, a.ages[age.ID]; incoming.youngerThan(existing) {
		return nil, zeroballot, AgeError{Incoming: incoming, Existing: existing}
	}
	av := a.values[key]
	if av.promise.greaterThan(b) {
		return av.value, av.promise, ConflictError{Proposed: b, Existing: av.promise, ExistingKind: "promise"}
	}
	if av.accepted.greaterThan(b) {
		return av.value, av.accepted, ConflictError{Proposed: b, Existing: av.accepted, ExistingKind: "accepted"}
	}
	av.promise = b
	a.values[key] = av
	return av.value, av.accepted, nil
}