From a4e26bf7c2c0cfc65be14ef98af695a0d663609f Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 23 Jun 2014 11:25:14 +0200 Subject: Added Block do which replays the given block or error --- ethereum.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index a6cb78b1f..77a7c92c7 100644 --- a/ethereum.go +++ b/ethereum.go @@ -113,6 +113,24 @@ func New(caps Caps, usePnp bool) (*Ethereum, error) { return ethereum, nil } +// Replay block +func (self *Ethereum) BlockDo(hash []byte) error { + block := self.blockChain.GetBlock(hash) + if block == nil { + return fmt.Errorf("unknown block %x", hash) + } + + parent := self.blockChain.GetBlock(block.PrevHash) + + _, err := self.stateManager.ApplyDiff(parent.State(), parent, block) + if err != nil { + return err + } + + return nil + +} + func (s *Ethereum) Reactor() *ethutil.ReactorEngine { return s.reactor } -- cgit