~whereswaldon/forest-go

51f57df771ef1dc05a0b9b951953322ed0f2dff5 — Chris Waldon 1 year, 11 months ago 96d8c65
Remove unused Size() method from Store interface
2 files changed, 1 insertions(+), 22 deletions(-)

M store.go
M store_test.go
M store.go => store.go +0 -11
@@ 8,7 8,6 @@ import (
)

type Store interface {
	Size() (int, error)
	CopyInto(Store) error
	Get(*fields.QualifiedHash) (Node, bool, error)
	GetIdentity(*fields.QualifiedHash) (Node, bool, error)


@@ 34,10 33,6 @@ func NewMemoryStore() *MemoryStore {
	}
}

func (m *MemoryStore) Size() (int, error) {
	return len(m.Items), nil
}

func (m *MemoryStore) CopyInto(other Store) error {
	for _, node := range m.Items {
		if err := other.Add(node); err != nil {


@@ 179,12 174,6 @@ func NewCacheStore(cache, back Store) (*CacheStore, error) {
	return &CacheStore{cache, back}, nil
}

// Size returns the effective size of this CacheStore, which is the size of the
// Back Store.
func (m *CacheStore) Size() (int, error) {
	return m.Back.Size()
}

// Get returns the requested node if it is present in either the Cache or the Back Store.
// If the cache is missed by the backing store is hit, the node will automatically be
// added to the cache.

M store_test.go => store_test.go +1 -11
@@ 13,11 13,6 @@ func TestMemoryStore(t *testing.T) {
}

func testStandardStoreInterface(t *testing.T, s forest.Store, storeImplName string) {
	if size, err := s.Size(); size != 0 {
		t.Errorf("Expected new %s to have size 0, had %d", storeImplName, size)
	} else if err != nil {
		t.Errorf("Expected new %s Size() to succeed, failed with %s", storeImplName, err)
	}
	// create three test nodes, one of each type
	identity, _, community, reply := MakeReplyOrSkip(t)
	nodes := []forest.Node{identity, community, reply}


@@ 49,15 44,10 @@ func testStandardStoreInterface(t *testing.T, s forest.Store, storeImplName stri
	}

	// add each node
	for count, i := range nodes {
	for _, i := range nodes {
		if err := s.Add(i); err != nil {
			t.Errorf("%s Add() should not err on Add(): %s", storeImplName, err)
		}
		if size, err := s.Size(); err != nil {
			t.Errorf("%s Size() should never error, got %s", storeImplName, err)
		} else if size != count+1 {
			t.Errorf("%s Size() should be %d after %d Add()s, got %d", storeImplName, count+1, count+1, size)
		}
	}

	// map each node to the getters that should be successful in fetching it