diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-11 05:44:53 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-11 05:44:53 +0800 |
commit | 8bbf879cb31e9cb28700773ed788421f9935ac36 (patch) | |
tree | ea2ab662a0577aa6238b084eda7ec9644ee35995 /block_manager.go | |
parent | f6fa4f88797030b8e83066cb262a68958953974e (diff) | |
download | dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.tar dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.tar.gz dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.tar.bz2 dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.tar.lz dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.tar.xz dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.tar.zst dexon-8bbf879cb31e9cb28700773ed788421f9935ac36.zip |
Moving the ethgo to individual packages
Diffstat (limited to 'block_manager.go')
-rw-r--r-- | block_manager.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/block_manager.go b/block_manager.go index 134ca0e75..59430dca7 100644 --- a/block_manager.go +++ b/block_manager.go @@ -2,17 +2,18 @@ package main import ( "fmt" + "github.com/ethereum/ethutil-go" ) type BlockChain struct { - lastBlock *Block + lastBlock *ethutil.Block - genesisBlock *Block + genesisBlock *ethutil.Block } func NewBlockChain() *BlockChain { bc := &BlockChain{} - bc.genesisBlock = NewBlock( Encode(Genesis) ) + bc.genesisBlock = ethutil.NewBlock( ethutil.Encode(ethutil.Genesis) ) return bc } @@ -30,19 +31,19 @@ func NewBlockManager() *BlockManager { } // Process a block. -func (bm *BlockManager) ProcessBlock(block *Block) error { +func (bm *BlockManager) ProcessBlock(block *ethutil.Block) error { // TODO Validation (Or move to other part of the application) if err := bm.ValidateBlock(block); err != nil { return err } // Get the tx count. Used to create enough channels to 'join' the go routines - txCount := len(block.transactions) + txCount := len(block.Transactions()) // Locking channel. When it has been fully buffered this method will return lockChan := make(chan bool, txCount) // Process each transaction/contract - for _, tx := range block.transactions { + for _, tx := range block.Transactions() { // If there's no recipient, it's a contract if tx.IsContract() { go bm.ProcessContract(tx, block, lockChan) @@ -60,11 +61,11 @@ func (bm *BlockManager) ProcessBlock(block *Block) error { return nil } -func (bm *BlockManager) ValidateBlock(block *Block) error { +func (bm *BlockManager) ValidateBlock(block *ethutil.Block) error { return nil } -func (bm *BlockManager) ProcessContract(tx *Transaction, block *Block, lockChan chan bool) { +func (bm *BlockManager) ProcessContract(tx *ethutil.Transaction, block *ethutil.Block, lockChan chan bool) { // Recovering function in case the VM had any errors defer func() { if r := recover(); r != nil { |