2017-11-02 19:37:07 +00:00
|
|
|
package observers
|
2017-10-25 15:57:59 +00:00
|
|
|
|
|
|
|
import (
|
2017-11-06 18:53:43 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/pkg/core"
|
|
|
|
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
2017-10-25 15:57:59 +00:00
|
|
|
)
|
|
|
|
|
2017-11-06 16:52:07 +00:00
|
|
|
type BlockchainDbObserver struct {
|
|
|
|
repository repositories.Repository
|
2017-10-25 15:57:59 +00:00
|
|
|
}
|
|
|
|
|
2017-11-06 16:52:07 +00:00
|
|
|
func NewBlockchainDbObserver(repository repositories.Repository) BlockchainDbObserver {
|
|
|
|
return BlockchainDbObserver{repository: repository}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (observer BlockchainDbObserver) NotifyBlockAdded(block core.Block) {
|
2017-12-19 20:14:41 +00:00
|
|
|
observer.repository.CreateOrUpdateBlock(block)
|
2017-10-25 15:57:59 +00:00
|
|
|
}
|