ipld-eth-server/fakes/blockchain_observer.go
Eric Meyer 646e0fa057 Refactor to use listener
* This removes some duplication between the fake blockchain and
   geth blockchain.
 * This pulls the observers into the blockchain listener
2017-11-02 12:51:46 -05:00

24 lines
571 B
Go

package fakes
import "github.com/8thlight/vulcanizedb/core"
type BlockchainObserver struct {
CurrentBlocks []core.Block
WasNotified chan bool
}
func (observer *BlockchainObserver) LastBlock() core.Block {
return observer.CurrentBlocks[len(observer.CurrentBlocks)-1]
}
func NewFakeBlockchainObserverTwo() *BlockchainObserver {
return &BlockchainObserver{
WasNotified: make(chan bool),
}
}
func (observer *BlockchainObserver) NotifyBlockAdded(block core.Block) {
observer.CurrentBlocks = append(observer.CurrentBlocks, block)
observer.WasNotified <- true
}