2017-10-23 15:56:29 +00:00
|
|
|
package fakes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/8thlight/vulcanizedb/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BlockchainObserver struct {
|
|
|
|
wasToldBlockAdded bool
|
2017-10-24 14:24:07 +00:00
|
|
|
blocks []core.Block
|
2017-10-23 15:56:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (blockchainObserver *BlockchainObserver) WasToldBlockAdded() bool {
|
|
|
|
return blockchainObserver.wasToldBlockAdded
|
|
|
|
}
|
|
|
|
|
|
|
|
func (blockchainObserver *BlockchainObserver) NotifyBlockAdded(block core.Block) {
|
2017-10-24 14:24:07 +00:00
|
|
|
blockchainObserver.blocks = append(blockchainObserver.blocks, block)
|
2017-10-23 15:56:29 +00:00
|
|
|
blockchainObserver.wasToldBlockAdded = true
|
|
|
|
}
|
2017-10-24 14:24:07 +00:00
|
|
|
|
|
|
|
func (observer *BlockchainObserver) LastAddedBlock() core.Block {
|
|
|
|
return observer.blocks[len(observer.blocks)-1]
|
|
|
|
}
|