Nest packages under pkg
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package fakes
|
||||
|
||||
import "github.com/8thlight/vulcanizedb/pkg/core"
|
||||
|
||||
type Blockchain struct {
|
||||
outputBlocks chan core.Block
|
||||
WasToldToStop bool
|
||||
}
|
||||
|
||||
func (blockchain *Blockchain) SubscribeToBlocks(outputBlocks chan core.Block) {
|
||||
blockchain.outputBlocks = outputBlocks
|
||||
}
|
||||
|
||||
func (blockchain Blockchain) AddBlock(block core.Block) {
|
||||
blockchain.outputBlocks <- block
|
||||
}
|
||||
|
||||
func (*Blockchain) StartListening() {}
|
||||
|
||||
func (blockchain *Blockchain) StopListening() {
|
||||
blockchain.WasToldToStop = true
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package fakes
|
||||
|
||||
import "github.com/8thlight/vulcanizedb/pkg/core"
|
||||
|
||||
type BlockchainObserver struct {
|
||||
CurrentBlocks []core.Block
|
||||
WasNotified chan bool
|
||||
}
|
||||
|
||||
func (observer *BlockchainObserver) LastBlock() core.Block {
|
||||
return observer.CurrentBlocks[len(observer.CurrentBlocks)-1]
|
||||
}
|
||||
|
||||
func NewFakeBlockchainObserver() *BlockchainObserver {
|
||||
return &BlockchainObserver{
|
||||
WasNotified: make(chan bool),
|
||||
}
|
||||
}
|
||||
|
||||
func (observer *BlockchainObserver) NotifyBlockAdded(block core.Block) {
|
||||
observer.CurrentBlocks = append(observer.CurrentBlocks, block)
|
||||
observer.WasNotified <- true
|
||||
}
|
||||
Reference in New Issue
Block a user