2017-10-23 15:56:29 +00:00
|
|
|
package fakes
|
|
|
|
|
2017-11-02 11:41:24 +00:00
|
|
|
import "github.com/8thlight/vulcanizedb/core"
|
2017-10-23 15:56:29 +00:00
|
|
|
|
|
|
|
type BlockchainObserver struct {
|
2017-11-02 11:41:24 +00:00
|
|
|
CurrentBlocks []core.Block
|
|
|
|
WasNotified chan bool
|
2017-10-23 15:56:29 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 11:41:24 +00:00
|
|
|
func (observer *BlockchainObserver) LastBlock() core.Block {
|
|
|
|
return observer.CurrentBlocks[len(observer.CurrentBlocks)-1]
|
2017-10-23 15:56:29 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 11:41:24 +00:00
|
|
|
func NewFakeBlockchainObserverTwo() *BlockchainObserver {
|
|
|
|
return &BlockchainObserver{
|
|
|
|
WasNotified: make(chan bool),
|
|
|
|
}
|
2017-10-23 15:56:29 +00:00
|
|
|
}
|
2017-10-24 14:24:07 +00:00
|
|
|
|
2017-11-02 11:41:24 +00:00
|
|
|
func (observer *BlockchainObserver) NotifyBlockAdded(block core.Block) {
|
|
|
|
observer.CurrentBlocks = append(observer.CurrentBlocks, block)
|
|
|
|
observer.WasNotified <- true
|
2017-10-24 14:24:07 +00:00
|
|
|
}
|