CN114553953A - Event pushing method for JAVA intelligent contract of block chain - Google Patents

Event pushing method for JAVA intelligent contract of block chain Download PDF

Info

Publication number
CN114553953A
CN114553953A CN202210181716.0A CN202210181716A CN114553953A CN 114553953 A CN114553953 A CN 114553953A CN 202210181716 A CN202210181716 A CN 202210181716A CN 114553953 A CN114553953 A CN 114553953A
Authority
CN
China
Prior art keywords
event
data
contract
user
topics
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210181716.0A
Other languages
Chinese (zh)
Inventor
邱炜伟
李伟
陶烨琪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202210181716.0A priority Critical patent/CN114553953A/en
Publication of CN114553953A publication Critical patent/CN114553953A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses an event pushing method of JAVA intelligent contract of a block chain, which can actively push a notification form of a client by realizing a log event generated by the JAVA intelligent contract on the block chain, wherein a virtual machine execution engine generates a unique contract address for each contract and instantiates a contract object, the object is used for processing all method calls sent to the contract address, after the virtual machine execution engine verifies that a request parameter is legal, the virtual machine execution engine starts to process a corresponding request and returns a result to the client, meanwhile, a user-defined contract event is triggered during the contract method call, the event content is sent to a block chain node, and the log event generated during the contract execution is pushed to the client after data is disqualified. Because the product is based on event pushing of JAVA contracts, a user can customize data and screening conditions of events, and the user can conveniently develop the events.

Description

Event pushing method for JAVA intelligent contract of block chain
The application is a divisional application proposed by a Chinese patent application with the application date of '22/8/2019', the application number of '201910776138.3' and the name of 'an event pushing method for a JAVA intelligent contract with a block chain'.
Technical Field
The invention relates to a blockchain technology, in particular to an event pushing method for a JAVA intelligent contract of a blockchain.
Background
The block chain technology is a novel decentralized protocol, digital currency transactions or other data can be safely stored, and information cannot be forged or falsified; the intelligent contract is a piece of code which can be deployed and executed in a blockchain network environment, the deployment and execution of the code can be presented in a transaction form in the blockchain network, and the deployment and execution results can be commonly known by the whole network along with the transaction; the languages supported by the intelligent contracts at present comprise identity, JAVA and the like, and the intelligent contracts are widely applied to various service applications based on block chains.
The traditional alliance blockchain intelligent contract execution engine comprises an EVM and a JVM, supported languages are a policy and JAVA respectively, but in a contract execution environment, the contract execution environment is a sandbox environment of a blockchain node, so that the external part is difficult to perceive the execution state inside a contract, the contract execution environment is difficult to monitor by a user, the judgment can be made only through a return result of the contract, particularly, the contract is an intelligent contract written in a JAVA language, unlike the situation that customized event pushing is difficult to realize in a specific intelligent contract language policy, and the execution condition of the contract is monitored through pushed data.
The decentralized and non-tamper-able characteristics of the blockchain provide a good development environment for the intelligent contract, so in recent years, a series of blockchain communities such as bitcoin networks and ether house networks successively start to provide an open intelligent contract programming interface. However, in the process of executing the intelligent contracts, an event pushing mode is lacked to inform the client of the intermediate process of executing the contracts, and particularly, an intelligent contract pushing method based on the current mainstream programming language is lacked.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides an event pushing method of a JAVA intelligent contract of a block chain, which realizes the whole event pushing process from the processes of generation, triggering, pushing, subscription, decoding and the like of an intelligent contract event, and the specific technical scheme is as follows:
a method for pushing events of JAVA intelligent contracts of block chains,
the virtual machine execution engine of the event is a JAVA virtual machine, receives a contract file in a JAR form and deploys on a block chain platform, loads the contract file through a self-defined class loader, initializes a contract instance, and calls an intelligent contract in an interface form;
the JAVA intelligent contract inherits from a BaseContract virtual class, the event pushing method is defined in a father class of the JAVA intelligent contract, and the event comprises topics filtering conditions and a data part;
the event pushing method specifically comprises the following steps:
s1: the event defined by the JAVA intelligent contract receives three parameters input by a user, wherein the first parameter is any type of Object data, namely data which the user finally wants to push to a client; the second parameter is a character string type, namely the name of the current event customized by the user, and the name can be finally used as a part of the topics filtering condition; the third parameter is a character string array with the type of any number and any length, and is used for adding filtering conditions for a user;
s2: when the intelligent contract method containing the event is called, the event is triggered, the execution engine serializes data expected to be pushed by a user and sends the serialized data to the block chain node together with topics filtering conditions, and after receiving event pushing information sent by the JAVA intelligent contract, the block chain node stores the contract address, the block number, the topics filtering conditions of the event and the data part of the current event into a state database;
s3: when the block to which the transaction containing the contract event belongs falls into the disk, the event distribution is triggered, the block chain nodes compare topics filtering conditions specified by the user for the subscription event with the events topics stored in the state database of the current block, and when the filtering conditions and the events are completely the same, the event is distributed to a subscription list of the user and the message is sent to the client according to a pushing form specified by the user.
Further, the topics filter conditions and data portion are specified before the push event is executed or when dynamically incoming from contract method parameters.
Further, the execution engine transmits data in JAVA to the blockchain node through a JNI method.
The invention has the beneficial effects that:
the invention is applied to a block chain platform, provides a set of brand-new intelligent contract event pushing method, realizes the generation, triggering, pushing, subscribing and decoding of contract events, and provides convenience for user contract monitoring. Meanwhile, the records generated by the contract events can be stored in the block chain state database, so that the user can conveniently inquire the records.
Drawings
FIG. 1 is a diagram of a contract event structure;
FIG. 2 is a contract event push diagram.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments, and the objects and effects of the present invention will be more apparent, it being understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the present invention.
As shown in fig. 1-2, an event pushing method for JAVA smart contracts of blockchains is characterized in that,
the virtual machine execution engine of the event is a JAVA virtual machine, receives a contract file in a JAR form and deploys on a block chain platform, loads the contract file through a self-defined class loader, initializes a contract instance, and calls an intelligent contract in an interface form;
the JAVA intelligent contract inherits from a BaseContract virtual class, the event pushing method is defined in a father class of the JAVA intelligent contract, and the event comprises topics filtering conditions and a data part;
the event pushing method specifically comprises the following steps:
s1: the event defined by the JAVA intelligent contract receives three parameters input by a user, wherein the first parameter is any type of Object data, namely data which the user finally wants to push to a client; the second parameter is a character string type, namely the name of the current event customized by the user, and the name can be finally used as a part of the topics filtering condition; the third parameter is a character string array with the type of any number and any length, and is used for adding filtering conditions for a user;
s2: when an intelligent contract method containing an event is called, the event is triggered, the execution engine serializes data expected to be pushed by a user, and sends the serialized data to a block chain node together with topics filtering conditions, and after receiving event pushing information sent by a JAVA intelligent contract, the block chain node stores a contract address, a block number, the topics filtering conditions of the event and data of the current event into a state database;
s3: when the block to which the transaction containing the contract event belongs falls into the disk, the event distribution is triggered, the block chain nodes compare topics filtering conditions specified by the user for the subscription event with the events topics stored in the state database of the current block, and when the filtering conditions and the events are completely the same, the event is distributed to a subscription list of the user and the message is sent to the client according to a pushing form specified by the user.
A user can send a subscription and reading request to a block chain node and acquire the pushed network connection at a client according to a required pushing form by adopting MQ or WebSocket, then an event meeting the conditions is sent through the network connection, and the user can specify a subscribed contract address, a block number interval and topics filtering conditions of the event when subscribing. After receiving the push data of the node, the data format is analyzed, the data which the user wants to push in the contract is taken out, the data is deserialized into a corresponding data structure to be used, if the user expects to specify different filtering conditions, multiple subscriptions can be sent to the node to create multiple push connections, and therefore the event push data of different subscriptions can be obtained.
In the first step, the defined event can specify any type of data, and the data form finally serialized and pushed to the client is light; multiple topics filtering conditions may be defined, extending more filtering forms for user subscriptions.
In the first step, after a user defines topics filtering conditions of a contract event, event push data can be a certain key data change state in the contract execution process, and special data is pushed to the specified topics filtering conditions, so that the user can receive and process the event push more accurately. And meanwhile, the use of events is very convenient, and a user only needs to call a parent method.
In the second step, the contract event is defined in the contract method, the defined contract event is automatically triggered as the contract method executes, and some data of the contract is transmitted to the event in the form of parameters, while topics can be determined by hard coding before the contract method executes or can be dynamically specified during the execution.
In the second step, after the contract event is triggered in the contract specifying process, the JAVA virtual machine execution engine sends the data in JAVA to the block chain platform through the JNI method, so that the cross-language form reduces much transmission overhead, and simultaneously, a piece of memory can be shared. And after the node receives the data pushed by the event, the data is stored in a state database.
In the second step, after the block where the transaction is located falls off the disk, the block chain node starts to distribute different events to the specified subscription channel from the state database, and the events and the subscribed events are pushed after comparing the events topics with the subscribed topics one by one and are the same.
In the second step, the user may open the MQ or WebSocket connection mode to obtain the subscribed data from the platform, and the subscription rule may specify a contract address, a block number range, a topics filtering condition, and the like.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the invention and is not intended to limit the invention to the particular forms disclosed, and that modifications may be made, or equivalents may be substituted for elements thereof, while remaining within the scope of the claims that follow. All modifications, equivalents and the like which come within the spirit and principle of the invention are intended to be included within the scope of the invention.

Claims (10)

1. An event pushing method for a JAVA intelligent contract of a blockchain is applied to a blockchain platform, and comprises the following steps:
receiving parameters input by a user, wherein the parameters comprise a first parameter, a second parameter and a third parameter, the first parameter is any type data of an Object type, the second parameter is character string type data, and the third parameter is a character string array with any number and any length; the first parameter is data which the user finally wants to push to the client; the second parameter is the name of an event defined by a user; the events comprise topics filtering conditions and data parts;
if the event is triggered, serializing data expected to be pushed by a user by adopting an execution engine on a blockchain platform, and sending the data expected to be pushed by the user and the topics filtering conditions to blockchain nodes through JAVA intelligent contracts; the block link point is used for distributing the event to a client after the block containing the event belongs to the block is landed; the execution engine is a JAVA virtual machine, and the JAVA virtual machine execution engine accepts contract files in the form of JARs to be deployed on the blockchain platform.
2. The method according to claim 1, wherein before the serializing the data that the user desires to push by using an execution engine on the blockchain platform if the event is triggered and then sending the data that the user desires to push to the blockchain node together with the topics filter condition through a JAVA smart contract, the method further comprises:
determining that the event is triggered when an intelligent contract method containing the event is invoked.
3. The method according to claim 1, wherein the blockchain node is further configured to, after receiving event push information sent by the JAVA intelligent contract, store the contract address, the block number, the topics filter condition, and the data portion of the event in a state database.
4. The method of claim 3, wherein the blockchain node is specifically configured to:
when the block to which the transaction containing the event belongs falls on the disk, the block chain node compares topics filtering conditions specified by the subscription request with the event topics stored in the state database of the current block; the subscription request is sent to the block chain node by the user at the client in a required push form, and the subscription request comprises a subscribed contract address, a block number interval and topics filtering conditions of an event;
when the topics filtering condition specified by the subscription request is completely the same as the event topics stored in the state database of the current block, the event is distributed to the subscription list of the user and is sent to the client according to the push form specified by the user.
5. The method of claim 4, wherein the sending the data desired to be pushed by the user and the topics filter condition to a blockchain node through a JAVA intelligent contract comprises:
and sending the data which is expected to be pushed by the user and the topics filtering condition to a block chain node by adopting a JNI method.
6. The method according to claim 5, before said sending data desired to be pushed by said user to blockchain nodes together with said topics filtering condition by using JNI method, further comprising:
a value is assigned to the contract address.
7. The method of any of claims 1-6, wherein the topics filtering conditions comprise a plurality, each of the topics filtering conditions being for implementing a different filtering modality.
8. An event pushing method for a JAVA intelligent contract of a blockchain is applied to a client, and comprises the following steps:
sending a book reading request to the block link points according to a pushing form required by a user and acquiring the pushed network connection;
receiving an event complying with the subscription request through the network connection, the event comprising topics filtering conditions and a data portion;
after receiving the pushed data of the block chain node, extracting the data which the user wants to push in the contract by analyzing the data format;
the data is deserialized into corresponding usable data structures.
9. The method of claim 8, further comprising:
and if the user desires to specify different filtering conditions, sending a multi-subscription request to the blockchain node to create a plurality of push connections, so as to obtain event push data corresponding to different subscription requests, wherein the multi-subscription request comprises different topics filtering conditions.
10. The method for pushing events of a blockchain JAVA smart contract according to claim 8 or 9, wherein the subscribed data is obtained by opening a connection mode of MQ or WebSocket.
CN202210181716.0A 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain Pending CN114553953A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210181716.0A CN114553953A (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210181716.0A CN114553953A (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain
CN201910776138.3A CN110535928B (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201910776138.3A Division CN110535928B (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain

Publications (1)

Publication Number Publication Date
CN114553953A true CN114553953A (en) 2022-05-27

Family

ID=68664023

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210181716.0A Pending CN114553953A (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain
CN201910776138.3A Active CN110535928B (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN201910776138.3A Active CN110535928B (en) 2019-08-22 2019-08-22 Event pushing method for JAVA intelligent contract of block chain

Country Status (1)

Country Link
CN (2) CN114553953A (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112214802B (en) * 2020-09-30 2023-04-28 电子科技大学 Block chain intelligent contract message publishing and subscribing method
CN112346820A (en) * 2020-11-16 2021-02-09 杭州复杂美科技有限公司 Block chain JVM application method, device and storage medium
CN112199221B (en) * 2020-12-04 2021-03-30 杭州趣链科技有限公司 Event pushing method, system, block chain platform, contract calling end and medium
CN112905554B (en) * 2021-02-07 2024-05-10 全链通有限公司 Block chain-based data sharing method and device
CN113222766B (en) * 2021-05-13 2023-02-07 杭州趣链科技有限公司 Information supervision method and device of financial product, computer equipment and medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107103473A (en) * 2017-04-27 2017-08-29 电子科技大学 A kind of intelligent contract implementation method based on block chain
CN107562513B (en) * 2017-07-18 2020-08-07 杭州趣链科技有限公司 Intelligent contract life cycle management method based on JAVA
US10963400B2 (en) * 2017-10-11 2021-03-30 International Business Machines Corporation Smart contract creation and monitoring for event identification in a blockchain
CN109582438B (en) * 2018-10-30 2021-05-28 广州斯拜若科技有限公司 Virtual machine with multiple intelligent contract execution engines and implementation method thereof
CN109710384B (en) * 2018-12-29 2021-02-23 杭州趣链科技有限公司 Safe Java intelligent contract interpretation execution engine and method
CN110097364A (en) * 2019-04-30 2019-08-06 翟红鹰 Block chain intelligence contract modularization generation method, system, terminal and storage medium

Also Published As

Publication number Publication date
CN110535928A (en) 2019-12-03
CN110535928B (en) 2022-04-01

Similar Documents

Publication Publication Date Title
CN110535928B (en) Event pushing method for JAVA intelligent contract of block chain
CN110535777B (en) Access request control method and device, electronic equipment and readable storage medium
CN113055421B (en) Service grid management method and system
CN109923847B (en) Discovery method, device, equipment and storage medium for call link
CN104219316A (en) Method and device for processing call request in distributed system
US20120203858A1 (en) Transaction control arrangement for device management system
CN101778004B (en) Terminal and method for performing device management scheduled based on threshold thereof
US7818752B2 (en) Interface for application components
US8490100B2 (en) Terminal and method for performing device management scheduled based on threshold
CN108462598A (en) A kind of daily record generation method, log analysis method and device
CN113300854B (en) Edge node capability expansion method, system and expansion box
CN109104368B (en) Connection request method, device, server and computer readable storage medium
CN109218401A (en) Log collection method, system, computer equipment and storage medium
US7975273B2 (en) Fuzzing system and method of distributed computing environment (DCE) remote procedure call (RPC)
CN110009347B (en) Block chain transaction information auditing method and device
CN115622906A (en) Application log capturing system and method
US8224933B2 (en) Method and apparatus for case-based service composition
CN116974948B (en) Service system testing method, system, equipment and medium
AU2005270897A1 (en) Client provisioning with linking
CN113177179A (en) Data request connection management method, device, equipment and storage medium
US7979531B2 (en) Method and system for network management data collection
WO1999034557A1 (en) Method and system for software version management in a network management system
CN112699183A (en) Data processing method, system, readable storage medium and computer equipment
CN106936643B (en) Equipment linkage method and terminal equipment
CN107103058B (en) Big data service combination method and composite service combination method based on Artifact

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination