Position: Home page » Ethereum » Ethereum RPC call

Ethereum RPC call

Publish: 2021-04-19 12:25:55
1. How to run Ethereum source code go Ethereum
install MIPS based Linux header file
$CD $prjroot / kernel
$tar - xjvf linux-2.6.38. Tar. Bz2
$CD linux-2.6.38

create an include folder under the specified path to store related header files< br />$ mkdir -p $TARGET_ Prefix / include

ensures that the Linux source code is clean
$make mrproper

generates the required header file< br />$ make ARCH=mips headers_ check
$ make ARCH=mips INSTALL_ HDR_ PATH=dest headers_ Install

all the files in dest folder to the specified include folder< br />$ cp -rv dest/include/* $TARGET_ Prefix / include

delete dest folder at last
$RM - RF dest
$LS - L $target_ PREFIX/include
2.

If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records

the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:

< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){
transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />});

Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query

recommend a practical introction, you can see: Ethereum tutorial

3. You can use the HTTP client protocol to include a set of JSON parameters and post them to the RPC server
after receiving the processing, the server will return a string, which should also be a set of JSON. If you parse it out, it will be the execution result
4. It's RPC.
RPC generally refers to calling remote code like calling local code, which is usually done by setting up a local agent
5. RPC is a remote procere call, which calls the other party function in a distributed system.
6.

关于RPC 路由器的实现主要分布在smd_rpcrouter.c、smd_rpcrouter_device.c、smd_rpcrouter_servers.c、smd_rpcrouter_clients.c等文件中RPC路由器起着RPC服务器查询、RPC服务器和RPC客户端的注册和销毁,以及底层通信的封装功能,类似于TCP协议

在实际的实现中,RPC路由器和RPC服务器均是作为一个虚拟的字符型设备来存在的

下面是RPC路由器的创建过程:

代码3-11 RPC 路由器的创建过程

int msm_rpcrouter_init_devices(void)

{

int rc;

int major;

msm_rpcrouter_class=class_create(THIS_MODULE,

"oncrpc"); //创建设备节点

if (IS_ERR(msm_rpcrouter_class)) {

rc=-ENOMEM;

printk(KERN_ERR

"rpcrouter: failed to create oncrpc class ");

goto fail;

}

rc=alloc_chrdev_region(&msm_rpcrouter_devno,

0, //作为字符型设备分配资源

RPCROUTER_MAX_REMOTE_SERVERS + 1, "oncrpc");

if (rc<0) {

printk(KERN_ERR

"rpcrouter: Failed to alloc chardev region (%d) ", rc);

goto fail_destroy_class;

}

major=MAJOR(msm_rpcrouter_devno);

rpcrouter_device=device_create(msm_

rpcrouter_class, NULL, //创建设备

msm_rpcrouter_devno, NULL, "%.8x:%d",

0, 0);

if (IS_ERR(rpcrouter_device)) {

rc=-ENOMEM;

goto fail_unregister_cdev_region;

}

cdev_init(&rpcrouter_cdev, &rpcrouter_

router_fops); //字符型设备初始化

rpcrouter_cdev.owner=THIS_MODULE;

rc=cdev_add(&rpcrouter_cdev, msm_rpcrouter_devno, 1);

if (rc<0)

goto fail_destroy_device;

return 0;

fail_destroy_device:

device_destroy(msm_rpcrouter_class,

msm_rpcrouter_devno);//销毁设备

fail_unregister_cdev_region:

unregister_chrdev_region(msm_rpcrouter_devno, //去注册

RPCROUTER_MAX_REMOTE_SERVERS + 1);

fail_destroy_class:

class_destroy(msm_rpcrouter_class);

fail:

return rc;

}

7. For HTTP, this is a short link. As far as I know, RPC is generally a long link. In the case of high traffic, it costs a lot to recreate the link. In addition, HTTP relies on container, if the container is not 6. Performance is sometimes dragged down by containers. When the data size of HTTP transmission is high, the same data transmission size of RPC and HTTP is different (most RPC uses binary, HTTP is generally JSON and so on). The big data here is on the one hand. Although a packet is not much big, the traffic is very expensive when the traffic is high. The efficiency of parsing JSON is not flattering. In fact, reliability and security are particularly attractive when the traffic is large. In fact, the scalability difference between the two is not very big. The rest is some automatic degradation and flow control functions of RPC to ensure the stability of services. Here's an example. For example, if you want to balance the load of HTTP, you usually use nginx to distribute. Once the traffic is high, you hang up one, and the second one will hang up. RPC usually comes with this function, or it is easy to implement. Of course, if you can implement the above-mentioned degradation and flow control functions, this is no problem ~ compared with security, HTTP data is easy to monitor.
8. Telnet calls RPC interface remotely, passes a number through invoke, and receives long type in the background. The code is int type. How to solve this problem? Telnet calls RPC interface remotely, passes a number through invoke, and receives long type in the background. The code is int type. How to solve this problem?
9. Statement will throw your custom exception. The exception program must try --- catch to handle or declare the throw exception, that is, throwsxxexception. If you want to try again or terminate the exception, you need to declare the throw exception, that is, to tell the virtual machine that running statement 1 may throw an exception
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750