Initial block reorganisation code

This commit is contained in:
Maran
2014-03-21 15:06:23 +01:00
parent ae837c4719
commit b52b1fca89
4 changed files with 210 additions and 31 deletions

View File

@ -201,7 +201,6 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
return nil
}
func (sm *StateManager) CalculateTD(block *Block) bool {
uncleDiff := new(big.Int)
for _, uncle := range block.Uncles {
@ -215,6 +214,9 @@ func (sm *StateManager) CalculateTD(block *Block) bool {
// The new TD will only be accepted if the new difficulty is
// is greater than the previous.
fmt.Println("new block td:", td)
fmt.Println("cur block td:", sm.bc.TD)
if td.Cmp(sm.bc.TD) > 0 {
// Set the new total difficulty back to the block chain
sm.bc.SetTotalDifficulty(td)