aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorStephenButtolph <[email protected]>2020-08-13 01:00:42 -0400
committerStephenButtolph <[email protected]>2020-08-13 01:00:42 -0400
commit4676ebb4aca5464e9ecba47f9db7e63593e92a0e (patch)
treef9fadccb1467e524ed87023318e1f9cf0842086f /plugin
parent4945ae1427399d9a0f6b3561306f50f360011613 (diff)
fixed nil pointer error in getCachedStatus + removed ip filterv0.2.8-rc.4
Diffstat (limited to 'plugin')
-rw-r--r--plugin/evm/vm.go34
1 files changed, 10 insertions, 24 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index 6c96870..7e9e205 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -10,8 +10,6 @@ import (
"errors"
"fmt"
"math/big"
- "net"
- "net/http"
"sync"
"sync/atomic"
"time"
@@ -359,23 +357,6 @@ func (vm *VM) LastAccepted() ids.ID {
return vm.lastAccepted.ID()
}
-type ipFilter struct {
- handler http.Handler
-}
-
-func (ipf ipFilter) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
- if ips, _, err := net.SplitHostPort(request.RemoteAddr); err == nil && ips == "127.0.0.1" {
- ipf.handler.ServeHTTP(writer, request)
- return
- }
- writer.WriteHeader(404)
- writer.Write([]byte("404 page not found\r\n"))
-}
-
-func newIPFilter(handler http.Handler) http.Handler {
- return ipFilter{handler}
-}
-
// CreateHandlers makes new http handlers that can handle API calls
func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler {
handler := vm.chain.NewRPCHandler()
@@ -387,8 +368,8 @@ func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler {
handler.RegisterName("admin", &admin.Performance{})
return map[string]*commonEng.HTTPHandler{
- "/rpc": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: newIPFilter(handler)},
- "/ws": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: newIPFilter(handler.WebsocketHandler([]string{"*"}))},
+ "/rpc": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler},
+ "/ws": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler.WebsocketHandler([]string{"*"})},
}
}
@@ -397,8 +378,8 @@ func (vm *VM) CreateStaticHandlers() map[string]*commonEng.HTTPHandler {
handler := rpc.NewServer()
handler.RegisterName("static", &StaticService{})
return map[string]*commonEng.HTTPHandler{
- "/rpc": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: newIPFilter(handler)},
- "/ws": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: newIPFilter(handler.WebsocketHandler([]string{"*"}))},
+ "/rpc": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler},
+ "/ws": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler.WebsocketHandler([]string{"*"})},
}
}
@@ -485,7 +466,12 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status {
highBlock, lowBlock = lowBlock, highBlock
}
for highBlock.Number().Cmp(lowBlock.Number()) > 0 {
- highBlock = vm.getBlock(ids.NewID(highBlock.ParentHash())).ethBlock
+ parentBlock := vm.getBlock(ids.NewID(highBlock.ParentHash()))
+ if parentBlock == nil {
+ vm.blockStatusCache.Put(blockID, choices.Processing)
+ return choices.Processing
+ }
+ highBlock = parentBlock.ethBlock
}
if highBlock.Hash() == lowBlock.Hash() { // on the same branch