示例#1
0
文件: web3.go 项目: codeaudit/shift
// create a new web3 api instance
func NewWeb3Api(xeth *xeth.XEth, coder codec.Codec) *web3Api {
	return &web3Api{
		xeth:    xeth,
		methods: Web3Mapping,
		codec:   coder.New(nil),
	}
}
示例#2
0
文件: http.go 项目: codeaudit/shift
// Create a new in process client
func NewHttpClient(cfg HttpConfig, c codec.Codec) *httpClient {
	return &httpClient{
		address: cfg.ListenAddress,
		port:    cfg.ListenPort,
		codec:   c.New(nil),
	}
}
示例#3
0
文件: miner.go 项目: codeaudit/shift
// create a new miner api instance
func NewMinerApi(ethereum *eth.Ethereum, coder codec.Codec) *minerApi {
	return &minerApi{
		ethereum: ethereum,
		methods:  MinerMapping,
		codec:    coder.New(nil),
	}
}
示例#4
0
文件: debug.go 项目: codeaudit/shift
// create a new debug api instance
func NewDebugApi(xeth *xeth.XEth, ethereum *eth.Ethereum, coder codec.Codec) *debugApi {
	return &debugApi{
		xeth:     xeth,
		ethereum: ethereum,
		methods:  DebugMapping,
		codec:    coder.New(nil),
	}
}
示例#5
0
文件: shh.go 项目: codeaudit/shift
// create a new whisper api instance
func NewShhApi(xeth *xeth.XEth, eth *eth.Ethereum, coder codec.Codec) *shhApi {
	return &shhApi{
		xeth:     xeth,
		ethereum: eth,
		methods:  shhMapping,
		codec:    coder.New(nil),
	}
}
示例#6
0
// create a new net api instance
func NewPersonalApi(xeth *xeth.XEth, eth *eth.Ethereum, coder codec.Codec) *personalApi {
	return &personalApi{
		xeth:     xeth,
		ethereum: eth,
		methods:  personalMapping,
		codec:    coder.New(nil),
	}
}
示例#7
0
文件: txpool.go 项目: codeaudit/shift
// create a new txpool api instance
func NewTxPoolApi(xeth *xeth.XEth, eth *eth.Ethereum, coder codec.Codec) *txPoolApi {
	return &txPoolApi{
		xeth:     xeth,
		ethereum: eth,
		methods:  txpoolMapping,
		codec:    coder.New(nil),
	}
}
示例#8
0
文件: net.go 项目: codeaudit/shift
// create a new net api instance
func NewNetApi(xeth *xeth.XEth, eth *eth.Ethereum, coder codec.Codec) *netApi {
	return &netApi{
		xeth:     xeth,
		ethereum: eth,
		methods:  netMapping,
		codec:    coder.New(nil),
	}
}
示例#9
0
文件: comms.go 项目: codeaudit/shift
func handle(id int, conn net.Conn, api shared.EthereumApi, c codec.Codec) {
	codec := c.New(conn)

	for {
		requests, isBatch, err := codec.ReadRequest()
		if err == io.EOF {
			codec.Close()
			return
		} else if err != nil {
			codec.Close()
			glog.V(logger.Debug).Infof("Closed IPC Conn %06d recv err - %v\n", id, err)
			return
		}

		if isBatch {
			responses := make([]*interface{}, len(requests))
			responseCount := 0
			for _, req := range requests {
				res, err := api.Execute(req)
				if req.Id != nil {
					rpcResponse := shared.NewRpcResponse(req.Id, req.Jsonrpc, res, err)
					responses[responseCount] = rpcResponse
					responseCount += 1
				}
			}

			err = codec.WriteResponse(responses[:responseCount])
			if err != nil {
				codec.Close()
				glog.V(logger.Debug).Infof("Closed IPC Conn %06d send err - %v\n", id, err)
				return
			}
		} else {
			var rpcResponse interface{}
			res, err := api.Execute(requests[0])

			rpcResponse = shared.NewRpcResponse(requests[0].Id, requests[0].Jsonrpc, res, err)
			err = codec.WriteResponse(rpcResponse)
			if err != nil {
				codec.Close()
				glog.V(logger.Debug).Infof("Closed IPC Conn %06d send err - %v\n", id, err)
				return
			}
		}
	}
}
示例#10
0
文件: admin.go 项目: codeaudit/shift
// create a new admin api instance
func NewAdminApi(xeth *xeth.XEth, ethereum *eth.Ethereum, codec codec.Codec) *adminApi {
	return &adminApi{
		xeth:     xeth,
		ethereum: ethereum,
		codec:    codec,
		coder:    codec.New(nil),
		ds:       docserver.New("/"),
	}
}
示例#11
0
func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
	c, err := Dial(cfg.Endpoint)
	if err != nil {
		return nil, err
	}

	coder := codec.New(c)
	msg := shared.Request{
		Id:      0,
		Method:  useragent.EnableUserAgentMethod,
		Jsonrpc: shared.JsonRpcVersion,
		Params:  []byte("[]"),
	}

	coder.WriteResponse(msg)
	coder.Recv()

	return &ipcClient{cfg.Endpoint, c, codec, coder}, nil
}
示例#12
0
文件: eth.go 项目: codeaudit/shift
// create new ethApi instance
func NewEthApi(xeth *xeth.XEth, eth *eth.Ethereum, codec codec.Codec) *ethApi {
	return &ethApi{xeth, eth, ethMapping, codec.New(nil)}
}