ipld-eth-server/pkg/repositories/in_memory.go
2017-11-06 13:06:03 -06:00

28 lines
535 B
Go

package repositories
import (
"github.com/8thlight/vulcanizedb/pkg/core"
)
type InMemory struct {
blocks map[int64]*core.Block
}
func NewInMemory() *InMemory {
return &InMemory{
blocks: make(map[int64]*core.Block),
}
}
func (repository *InMemory) CreateBlock(block core.Block) {
repository.blocks[block.Number] = &block
}
func (repository *InMemory) BlockCount() int {
return len(repository.blocks)
}
func (repository *InMemory) FindBlockByNumber(blockNumber int64) *core.Block {
return repository.blocks[blockNumber]
}