Separate repositories (#25)

* Separate Repository into multiple Repositories

* Use struct scan for transactions

* Use struct scan for blocks

* Remove unused block repo methods

* Update naming

* Rename / Cleanup repository related fields
This commit is contained in:
Matt K
2018-02-02 15:53:16 -06:00
committed by GitHub
parent 3863bcb614
commit aea9c7b5e2
35 changed files with 1440 additions and 1322 deletions
+7 -7
View File
@@ -1,12 +1,12 @@
package history_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/history"
"github.com/vulcanize/vulcanizedb/pkg/repositories"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/repositories/inmemory"
)
var _ = Describe("Populating blocks", func() {
@@ -17,7 +17,7 @@ var _ = Describe("Populating blocks", func() {
{Number: 2},
}
blockchain := fakes.NewBlockchainWithBlocks(blocks)
repository := repositories.NewInMemory()
repository := inmemory.NewInMemory()
repository.CreateOrUpdateBlock(core.Block{Number: 2})
blocksAdded := history.PopulateMissingBlocks(blockchain, repository, 1)
@@ -40,7 +40,7 @@ var _ = Describe("Populating blocks", func() {
{Number: 12},
{Number: 13},
})
repository := repositories.NewInMemory()
repository := inmemory.NewInMemory()
repository.CreateOrUpdateBlock(core.Block{Number: 1})
repository.CreateOrUpdateBlock(core.Block{Number: 2})
repository.CreateOrUpdateBlock(core.Block{Number: 3})
@@ -72,7 +72,7 @@ var _ = Describe("Populating blocks", func() {
{Number: 5},
{Number: 6},
})
repository := repositories.NewInMemory()
repository := inmemory.NewInMemory()
repository.CreateOrUpdateBlock(core.Block{Number: 3})
repository.CreateOrUpdateBlock(core.Block{Number: 6})
@@ -89,7 +89,7 @@ var _ = Describe("Populating blocks", func() {
{Number: 4},
{Number: 5},
})
repository := repositories.NewInMemory()
repository := inmemory.NewInMemory()
history.RetrieveAndUpdateBlocks(blockchain, repository, history.MakeRange(2, 5))
Expect(repository.BlockCount()).To(Equal(3))
+5 -5
View File
@@ -6,12 +6,12 @@ import (
"io/ioutil"
"log"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/history"
"github.com/vulcanize/vulcanizedb/pkg/repositories"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/repositories/inmemory"
)
func init() {
@@ -47,7 +47,7 @@ var _ = Describe("Blocks validator", func() {
{Number: 6},
{Number: 7},
})
repository := repositories.NewInMemory()
repository := inmemory.NewInMemory()
validator := history.NewBlockValidator(blockchain, repository, 2)
window := validator.ValidateBlocks()
@@ -62,7 +62,7 @@ var _ = Describe("Blocks validator", func() {
history.ParsedWindowTemplate.Execute(expectedMessage, history.ValidationWindow{5, 7})
blockchain := fakes.NewBlockchainWithBlocks([]core.Block{})
repository := repositories.NewInMemory()
repository := inmemory.NewInMemory()
validator := history.NewBlockValidator(blockchain, repository, 2)
actualMessage := &bytes.Buffer{}
validator.Log(actualMessage, window)