mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-27 05:57:28 +00:00
0be3044b7e
* rename * rename "make grpc" * rename "abi bindings templates" * rename "abi bindings templates"
44 lines
708 B
Go
44 lines
708 B
Go
package cli
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
|
)
|
|
|
|
type allowListFile struct {
|
|
Allow rpc.AllowList `json:"allow"`
|
|
}
|
|
|
|
func parseAllowListForRPC(path string) (rpc.AllowList, error) {
|
|
path = strings.TrimSpace(path)
|
|
if path == "" { // no file is provided
|
|
return nil, nil
|
|
}
|
|
|
|
file, err := os.Open(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer func() {
|
|
file.Close() //nolint: errcheck
|
|
}()
|
|
|
|
fileContents, err := ioutil.ReadAll(file)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var allowListFileObj allowListFile
|
|
|
|
err = json.Unmarshal(fileContents, &allowListFileObj)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return allowListFileObj.Allow, nil
|
|
}
|