aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-05 16:14:58 +0800
committerobscuren <geffobscura@gmail.com>2015-03-05 16:14:58 +0800
commitc47866d25174bd783ee6bcd5b400d81d7bf598bb (patch)
tree01c71c40981f4f75e1721011006d2da96dfc3c2d /core/chain_manager.go
parent15f491e5007d1507f20d0edce36cc9c0bd5cbd37 (diff)
downloaddexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.tar
dexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.tar.gz
dexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.tar.bz2
dexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.tar.lz
dexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.tar.xz
dexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.tar.zst
dexon-c47866d25174bd783ee6bcd5b400d81d7bf598bb.zip
Miner fixes and updates (including miner)
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index f2382cf8d..d2a6560c1 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -31,15 +31,18 @@ type StateQuery interface {
func CalcDifficulty(block, parent *types.Header) *big.Int {
diff := new(big.Int)
- //adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
- //if block.Time() >= parent.Time()+8 {
- adjust := new(big.Int).Div(parent.Difficulty, big.NewInt(2048))
+ min := big.NewInt(2048)
+ adjust := new(big.Int).Div(parent.Difficulty, min)
if (block.Time - parent.Time) < 8 {
diff.Add(parent.Difficulty, adjust)
} else {
diff.Sub(parent.Difficulty, adjust)
}
+ if diff.Cmp(GenesisDiff) < 0 {
+ return GenesisDiff
+ }
+
return diff
}
@@ -378,9 +381,12 @@ func (bc *ChainManager) Stop() {
}
func (self *ChainManager) InsertChain(chain types.Blocks) error {
+ println("insert chain start")
self.tsmu.Lock()
defer self.tsmu.Unlock()
+ defer println("insert chain end")
+
for _, block := range chain {
// Call in to the block processor and check for errors. It's likely that if one block fails
// all others will fail too (unless a known block is returned).
@@ -422,14 +428,18 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self.mu.Unlock()
if canonical {
- jsonlogger.LogJson(&logger.EthChainNewHead{
- BlockHash: ethutil.Bytes2Hex(block.Hash()),
- BlockNumber: block.Number(),
- ChainHeadHash: ethutil.Bytes2Hex(cblock.Hash()),
- BlockPrevHash: ethutil.Bytes2Hex(block.ParentHash()),
- })
+ /*
+ jsonlogger.LogJson(&logger.EthChainNewHead{
+ BlockHash: ethutil.Bytes2Hex(block.Hash()),
+ BlockNumber: block.Number(),
+ ChainHeadHash: ethutil.Bytes2Hex(cblock.Hash()),
+ BlockPrevHash: ethutil.Bytes2Hex(block.ParentHash()),
+ })
+ */
self.setTransState(state.New(block.Root(), self.db))
self.eventMux.Post(ChainEvent{block, td})
+ } else {
+ //self.eventMux.
}
if split {