Updated to new methods

This commit is contained in:
obscuren 2014-12-18 13:17:24 +01:00
parent 49e0267fe7
commit 2d09e67713
8 changed files with 16 additions and 9 deletions

View File

@ -66,7 +66,7 @@ func (self *BlockPool) HasLatestHash() bool {
self.mut.Lock()
defer self.mut.Unlock()
return self.pool[string(self.eth.ChainManager().CurrentBlock.Hash())] != nil
return self.pool[string(self.eth.ChainManager().CurrentBlock().Hash())] != nil
}
func (self *BlockPool) HasCommonHash(hash []byte) bool {

View File

@ -77,7 +77,7 @@ func main() {
var block *types.Block
if len(DumpHash) == 0 && DumpNumber == -1 {
block = ethereum.ChainManager().CurrentBlock
block = ethereum.ChainManager().CurrentBlock()
} else if len(DumpHash) > 0 {
block = ethereum.ChainManager().GetBlock(ethutil.Hex2Bytes(DumpHash))
} else {

View File

@ -149,7 +149,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
self.SetAsm(script)
block := self.lib.eth.ChainManager().CurrentBlock
block := self.lib.eth.ChainManager().CurrentBlock()
env := utils.NewEnv(statedb, block, account.Address(), value)

View File

@ -246,7 +246,7 @@ func (gui *Gui) CreateAndSetPrivKey() (string, string, string, string) {
}
func (gui *Gui) setInitialChain(ancientBlocks bool) {
sBlk := gui.eth.ChainManager().LastBlockHash
sBlk := gui.eth.ChainManager().LastBlockHash()
blk := gui.eth.ChainManager().GetBlock(sBlk)
for ; blk != nil; blk = gui.eth.ChainManager().GetBlock(sBlk) {
sBlk = blk.PrevHash
@ -468,7 +468,7 @@ func (gui *Gui) update() {
case <-peerUpdateTicker.C:
gui.setPeerInfo()
case <-generalUpdateTicker.C:
statusText := "#" + gui.eth.ChainManager().CurrentBlock.Number.String()
statusText := "#" + gui.eth.ChainManager().CurrentBlock().Number.String()
lastBlockLabel.Set("text", statusText)
miningLabel.Set("text", "Mining @ "+strconv.FormatInt(gui.uiLib.miner.GetPow().GetHashrate(), 10)+"Khash")

View File

@ -74,6 +74,13 @@ func (self *ChainManager) LastBlockNumber() uint64 {
return self.lastBlockNumber
}
func (self *ChainManager) LastBlockHash() []byte {
self.mu.RLock()
defer self.mu.RUnlock()
return self.lastBlockHash
}
func (self *ChainManager) CurrentBlock() *types.Block {
self.mu.RLock()
defer self.mu.RUnlock()

View File

@ -666,8 +666,8 @@ func (self *Peer) pushStatus() {
msg := wire.NewMessage(wire.MsgStatusTy, []interface{}{
uint32(ProtocolVersion),
uint32(NetVersion),
self.ethereum.ChainManager().TD,
self.ethereum.ChainManager().CurrentBlock.Hash(),
self.ethereum.ChainManager().Td(),
self.ethereum.ChainManager().CurrentBlock().Hash(),
self.ethereum.ChainManager().Genesis().Hash(),
})

View File

@ -29,7 +29,7 @@ func (self *JSXEth) BlockByHash(strHash string) *JSBlock {
func (self *JSXEth) BlockByNumber(num int32) *JSBlock {
if num == -1 {
return NewJSBlock(self.obj.ChainManager().CurrentBlock)
return NewJSBlock(self.obj.ChainManager().CurrentBlock())
}
return NewJSBlock(self.obj.ChainManager().GetBlockByNumber(uint64(num)))

View File

@ -82,7 +82,7 @@ func (self *XEth) Execute(addr []byte, data []byte, value, gas, price *ethutil.V
func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
var (
initiator = state.NewStateObject(self.obj.KeyManager().KeyPair().Address())
block = self.chainManager.CurrentBlock
block = self.chainManager.CurrentBlock()
)
self.Vm.State = self.World().State().Copy()