Remove defunct calls
This commit is contained in:
parent
540c79e6ad
commit
fb2488235a
78
rpc/api.go
78
rpc/api.go
@ -52,7 +52,7 @@ type EthereumApi struct {
|
||||
|
||||
db ethutil.Database
|
||||
|
||||
defaultBlockAge int64
|
||||
// defaultBlockAge int64
|
||||
}
|
||||
|
||||
func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
|
||||
@ -65,7 +65,7 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
|
||||
logs: make(map[int]*logFilter),
|
||||
messages: make(map[int]*whisperFilter),
|
||||
db: db,
|
||||
defaultBlockAge: -1,
|
||||
// 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":
|
||||
|
Loading…
Reference in New Issue
Block a user