Remove defunct calls

This commit is contained in:
Taylor Gerring 2015-03-02 09:36:48 -06:00
parent 540c79e6ad
commit fb2488235a

View File

@ -52,20 +52,20 @@ type EthereumApi struct {
db ethutil.Database
defaultBlockAge int64
// defaultBlockAge int64
}
func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
db, _ := ethdb.NewLDBDatabase("dapps")
api := &EthereumApi{
eth: eth,
mux: eth.Backend().EventMux(),
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(eth.Backend().EventMux()),
logs: make(map[int]*logFilter),
messages: make(map[int]*whisperFilter),
db: db,
defaultBlockAge: -1,
eth: eth,
mux: eth.Backend().EventMux(),
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(eth.Backend().EventMux()),
logs: make(map[int]*logFilter),
messages: make(map[int]*whisperFilter),
db: db,
// defaultBlockAge: -1,
}
go api.filterManager.Start()
go api.start()
@ -73,36 +73,36 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
return api
}
func (self *EthereumApi) setStateByBlockNumber(num int64) {
chain := self.xeth().Backend().ChainManager()
var block *types.Block
// func (self *EthereumApi) setStateByBlockNumber(num int64) {
// chain := self.xeth().Backend().ChainManager()
// var block *types.Block
if self.defaultBlockAge < 0 {
num = chain.CurrentBlock().Number().Int64() + num + 1
}
block = chain.GetBlockByNumber(uint64(num))
// if self.defaultBlockAge < 0 {
// num = chain.CurrentBlock().Number().Int64() + num + 1
// }
// block = chain.GetBlockByNumber(uint64(num))
if block != nil {
self.useState(state.New(block.Root(), self.xeth().Backend().Db()))
} else {
self.useState(chain.State())
}
}
// if block != nil {
// self.useState(state.New(block.Root(), self.xeth().Backend().Db()))
// } else {
// self.useState(chain.State())
// }
// }
func (self *EthereumApi) start() {
timer := time.NewTicker(filterTickerTime)
events := self.mux.Subscribe(core.ChainEvent{})
// events := self.mux.Subscribe(core.ChainEvent{})
done:
for {
select {
case ev := <-events.Chan():
switch ev.(type) {
case core.ChainEvent:
if self.defaultBlockAge < 0 {
self.setStateByBlockNumber(self.defaultBlockAge)
}
}
// case ev := <-events.Chan():
// switch ev.(type) {
// case core.ChainEvent:
// if self.defaultBlockAge < 0 {
// self.setStateByBlockNumber(self.defaultBlockAge)
// }
// }
case <-timer.C:
self.logMut.Lock()
self.messagesMut.Lock()
@ -365,24 +365,6 @@ func (p *EthereumApi) GetIsMining(reply *interface{}) error {
return nil
}
func (p *EthereumApi) SetMining(shouldmine bool, reply *interface{}) error {
*reply = p.xeth().SetMining(shouldmine)
return nil
}
func (p *EthereumApi) GetDefaultBlockAge(reply *interface{}) error {
*reply = p.defaultBlockAge
return nil
}
func (p *EthereumApi) SetDefaultBlockAge(defaultBlockAge int64, reply *interface{}) error {
p.defaultBlockAge = defaultBlockAge
p.setStateByBlockNumber(p.defaultBlockAge)
*reply = true
return nil
}
func (p *EthereumApi) BlockNumber(reply *interface{}) error {
*reply = p.xeth().Backend().ChainManager().CurrentBlock().Number()
return nil
@ -515,20 +497,6 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return p.GetCoinbase(reply)
case "eth_mining":
return p.GetIsMining(reply)
case "eth_setMining":
args, err := req.ToBoolArgs()
if err != nil {
return err
}
return p.SetMining(args, reply)
case "eth_defaultBlock":
return p.GetDefaultBlockAge(reply)
case "eth_setDefaultBlock":
args, err := req.ToIntArgs()
if err != nil {
return err
}
return p.SetDefaultBlockAge(int64(args), reply)
case "eth_number":
return p.BlockNumber(reply)
case "eth_accounts":