Small tweaks
This commit is contained in:
parent
3558dd5ed4
commit
782910eaa7
|
@ -146,8 +146,6 @@ func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte
|
||||||
log.Println("[CHAIN] At genesis block, breaking")
|
log.Println("[CHAIN] At genesis block, breaking")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
log.Printf("CHECKING OUR OWN BLOCKS: %x", block.Hash())
|
|
||||||
log.Printf("%x", bc.GenesisBlock().Hash())
|
|
||||||
curChainDifficulty.Add(curChainDifficulty, bc.CalculateBlockTD(block))
|
curChainDifficulty.Add(curChainDifficulty, bc.CalculateBlockTD(block))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +307,6 @@ func (bc *BlockChain) Add(block *Block) {
|
||||||
bc.LastBlockHash = block.Hash()
|
bc.LastBlockHash = block.Hash()
|
||||||
|
|
||||||
encodedBlock := block.RlpEncode()
|
encodedBlock := block.RlpEncode()
|
||||||
log.Println(encodedBlock)
|
|
||||||
ethutil.Config.Db.Put(block.Hash(), encodedBlock)
|
ethutil.Config.Db.Put(block.Hash(), encodedBlock)
|
||||||
ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock)
|
ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock)
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,6 @@ func (miner *Miner) listener() {
|
||||||
err := miner.ethereum.StateManager().ProcessBlock(miner.block, true)
|
err := miner.ethereum.StateManager().ProcessBlock(miner.block, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error result from process block:", err)
|
log.Println("Error result from process block:", err)
|
||||||
log.Println(miner.block)
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if !miner.ethereum.StateManager().Pow.Verify(miner.block.HashNoNonce(), miner.block.Difficulty, miner.block.Nonce) {
|
if !miner.ethereum.StateManager().Pow.Verify(miner.block.HashNoNonce(), miner.block.Difficulty, miner.block.Nonce) {
|
||||||
|
@ -138,7 +137,6 @@ func (miner *Miner) listener() {
|
||||||
}
|
}
|
||||||
miner.ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{miner.block.Value().Val})
|
miner.ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{miner.block.Value().Val})
|
||||||
log.Printf("[MINER] 🔨 Mined block %x\n", miner.block.Hash())
|
log.Printf("[MINER] 🔨 Mined block %x\n", miner.block.Hash())
|
||||||
log.Println(miner.block)
|
|
||||||
|
|
||||||
miner.txs = []*ethchain.Transaction{} // Move this somewhere neat
|
miner.txs = []*ethchain.Transaction{} // Move this somewhere neat
|
||||||
miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs)
|
miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs)
|
||||||
|
|
9
peer.go
9
peer.go
|
@ -337,16 +337,16 @@ func (p *Peer) HandleInbound() {
|
||||||
block = ethchain.NewBlockFromRlpValue(msg.Data.Get(i))
|
block = ethchain.NewBlockFromRlpValue(msg.Data.Get(i))
|
||||||
// Do we have this block on our chain? If so we can continue
|
// Do we have this block on our chain? If so we can continue
|
||||||
if p.ethereum.StateManager().BlockChain().HasBlock(block.Hash()) {
|
if p.ethereum.StateManager().BlockChain().HasBlock(block.Hash()) {
|
||||||
fmt.Println("[PEER] Block found, checking next one.")
|
ethutil.Config.Log.Debugf("[PEER] Block found, checking next one.\n")
|
||||||
} else {
|
} else {
|
||||||
// We don't have this block, but we do have a block with the same prevHash, diversion time!
|
// We don't have this block, but we do have a block with the same prevHash, diversion time!
|
||||||
if p.ethereum.StateManager().BlockChain().HasBlockWithPrevHash(block.PrevHash) {
|
if p.ethereum.StateManager().BlockChain().HasBlockWithPrevHash(block.PrevHash) {
|
||||||
fmt.Printf("[PEER] Local and foreign chain have diverted after %x, we are going to get freaky with it!\n", block.PrevHash)
|
ethutil.Config.Log.Infof("[PEER] Local and foreign chain have diverted after %x, finding best chain!\n", block.PrevHash)
|
||||||
if p.ethereum.StateManager().BlockChain().FindCanonicalChainFromMsg(msg, block.PrevHash) {
|
if p.ethereum.StateManager().BlockChain().FindCanonicalChainFromMsg(msg, block.PrevHash) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("[PEER] Both local and foreign chain have same parent. Continue normally")
|
ethutil.Config.Log.Debugf("[PEER] Both local and foreign chain have same parent. Continue normally\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,6 @@ func (p *Peer) HandleInbound() {
|
||||||
if ethutil.Config.Debug {
|
if ethutil.Config.Debug {
|
||||||
ethutil.Config.Log.Infof("[PEER] Block %x failed\n", block.Hash())
|
ethutil.Config.Log.Infof("[PEER] Block %x failed\n", block.Hash())
|
||||||
ethutil.Config.Log.Infof("[PEER] %v\n", err)
|
ethutil.Config.Log.Infof("[PEER] %v\n", err)
|
||||||
ethutil.Config.Log.Infoln(block)
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
|
@ -637,8 +636,6 @@ func (p *Peer) SyncWithBlocks() {
|
||||||
if p.blocksRequested == 0 {
|
if p.blocksRequested == 0 {
|
||||||
p.blocksRequested = 10
|
p.blocksRequested = 10
|
||||||
}
|
}
|
||||||
fmt.Printf("Currenb lock %x\n", p.ethereum.BlockChain().CurrentBlock.Hash())
|
|
||||||
fmt.Println("Amount:", p.blocksRequested)
|
|
||||||
blocks := p.ethereum.BlockChain().GetChain(p.ethereum.BlockChain().CurrentBlock.Hash(), p.blocksRequested)
|
blocks := p.ethereum.BlockChain().GetChain(p.ethereum.BlockChain().CurrentBlock.Hash(), p.blocksRequested)
|
||||||
|
|
||||||
var hashes []interface{}
|
var hashes []interface{}
|
||||||
|
|
Loading…
Reference in New Issue