KR20200065655A - Microgrid energy transaction based on cloud - Google Patents

Microgrid energy transaction based on cloud Download PDF

Info

Publication number
KR20200065655A
KR20200065655A KR1020180152328A KR20180152328A KR20200065655A KR 20200065655 A KR20200065655 A KR 20200065655A KR 1020180152328 A KR1020180152328 A KR 1020180152328A KR 20180152328 A KR20180152328 A KR 20180152328A KR 20200065655 A KR20200065655 A KR 20200065655A
Authority
KR
South Korea
Prior art keywords
block
transaction
chain
value
energy
Prior art date
Application number
KR1020180152328A
Other languages
Korean (ko)
Inventor
임창균
장지원
Original Assignee
주식회사 로그인서광
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 주식회사 로그인서광 filed Critical 주식회사 로그인서광
Priority to KR1020180152328A priority Critical patent/KR20200065655A/en
Publication of KR20200065655A publication Critical patent/KR20200065655A/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/06Energy or water supply
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0607Regulated
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0609Buyer or seller confidence or verification
    • 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/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/56Financial cryptography, e.g. electronic payment or e-cash

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Development Economics (AREA)
  • Health & Medical Sciences (AREA)
  • Water Supply & Treatment (AREA)
  • Public Health (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Resources & Organizations (AREA)
  • Primary Health Care (AREA)
  • Tourism & Hospitality (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The present invention relates to small energy transaction based on cloud to enable optimal peer to peer (P2P) transaction by matching a prosumer and a consumer in real time through a power trading platform based on blockchain. The small energy transaction based on cloud may enable to sell the remaining energy after using produced energy to electric power market, an electricity provider, and other consumers.

Description

클라우드 기반 소규모 에너지 거래{MICROGRID ENERGY TRANSACTION BASED ON CLOUD}MICROGRID ENERGY TRANSACTION BASED ON CLOUD}

본 발명은 클라우드 기반 소규모 에너지 거래에 관한 것이다.The present invention relates to cloud-based small-scale energy trading.

소규모 프로슈머 전력거래 프로그램이란 전력을 생산하여 사용하고 남은 에너지를 전력시장, 전기판매사업자 및 다른 소비자에게 판매할 수 있게 하는 거래이다. A small-scale prosumer electricity trading program is a transaction that allows electricity to be generated and used and the remaining energy to be sold to the electricity market, electricity suppliers, and other consumers.

전력을 생산하여 사용하고 남은 에너지를 전력시장, 전기판매사업자 및 다른 소비자에게 판매할 수 있게 하는데 목적이 있다. The purpose is to make it possible to generate and use power and sell the remaining energy to the power market, electricity vendors, and other consumers.

블록체인 기반 전력거래 플랫폼을 통해 실시간으로 최적의 프로슈머와 소비자를 매칭하고 P2P(peer to peer) 거래 할 수 있도록 하는 클라우드 기반 소규모 에너지 거래.A cloud-based small-scale energy transaction that enables optimal peer-to-peer (P2P) transactions by matching the optimal prosumers and consumers in real time through a blockchain-based power trading platform.

전력을 생산하여 사용하고 남은 에너지를 전력시장, 전기판매사업자 및 다른 소비자에게 판매할 수 있게 된다.It will be possible to generate and use the electricity and sell the remaining energy to the electricity market, electricity vendors and other consumers.

도 1. 클라우드 기반 소규모 에너지 거래를 위한 블록 다이어그램.
도 2. 에너지 거래 경매를 통한 블록체인 생성과정.
도 4. app.route() 에 사용되는 GET, POST, PUT의 사용.
도 5. 반환값의 상태코드.
Figure 1. Block diagram for small cloud-based energy trading.
Figure 2. Blockchain creation process through energy transaction auction.
Figure 4. Use of GET, POST, and PUT used in app.route().
Figure 5. Status code of the return value.

I. 소개I. Introduction

소규모 프로슈머 전력거래 프로그램이란 전력을 생산하여 사용하고 남은 에너지를 전력시장, 전기판매사업자 및 다른 소비자에게 판매할 수 있게 하는 거래이다.본 연구에서는 블록체인 기반 전력거래 플랫폼을 통해 실시간으로 최적의 프로슈머와 소비자를 매칭하고 P2P(peer to peer) 거래 할 수 있도록 한다. 탈 중앙화 에너지 거래 및 공급 시스템에서 거래 (프로슈머- 컨슈머 매칭)는 스마트 계약을 기반으로 완전 자동으로 또는 수동으로 수행된다. 각 트랜잭션은 변조 방지 방식을 따르고 이는 블록체인에 기록된다. 거래 완료 후 에너지는 네트워크를 통해 전달된다.A small-scale prosumer power trading program is a transaction that allows electricity to be generated and used and the remaining energy to be sold to the electricity market, electricity sales companies, and other consumers. Match consumers and enable peer-to-peer (P2P) transactions. In the decentralized energy trading and supply system, trading (prosumer-consumer matching) is performed either fully automatically or manually based on smart contracts. Each transaction follows a tamper-proof method, which is recorded on the blockchain. After the transaction is completed, energy is transferred through the network.

블록체인은 에너지 거래 분야에 적용하면 소위 "피어 - 투 - 피어 (peer-to-peer: P2P)"가 가능할 수 있게 하는 기술이다. 거래를 위해 네트워크의 모든 참가자는 제 3자 중개자 없이 네트워크 모든 참여자와 직접 거래 할 수 있다. Blockchain is a technology that enables so-called "peer-to-peer (P2P)" when applied to the field of energy trading. For trading, any participant in the network can trade directly with any participant in the network without a third party intermediary.

√거래를 위해 일반적인 블록체인은 다음과 같이 작동된다. √ For trading, the general blockchain works as follows.

1. 공급자와 고객이 직접 거래를 체결하는 것에 동의하면 거래 관련 판매자와 구매자가 되며 발신자 및 크기를 지정하여 이 거래의 변수를 결정한다. (모든 거래는 품질, 가격, 수량 등과 같은 사전 정의 된 개별 규칙을 기반으로 하는 지능적인 계약을 토대로 이루어진다)1. If the supplier and the customer agree to enter into a direct transaction, they become the seller and the buyer related to the transaction and determine the variables of this transaction by specifying the sender and size. (All transactions are based on intelligent contracts based on pre-defined individual rules such as quality, price, quantity, etc.)

2. 개별 거래와 관련된 모든 정보는 동일한 기간 동안 이루어진 다른 거래의 세부 정보와 결합되어 새로운 데이터 블록을 생성한다. (모든 거래 데이터는 분산된 블록체인에 저장되며 모든 관련 정보는 모든 참가자의 컴퓨터에 동일하게 저장된다)2. All information related to an individual transaction is combined with details of other transactions made during the same period to create a new data block. (All transaction data is stored on a distributed blockchain, and all relevant information is stored identically on all participants' computers)

3. 블록체인은 이 프로세스가 단일 표준화 된 트랜잭션과 관련된다는 점에서 다르다.3. Blockchain is different in that this process involves a single standardized transaction.

4. 각 트랜잭션은 암호화되어 많은 개별 컴퓨터 (피어 - 투 - 피어)에 배포되며 각 컴퓨터는 데이터를 로컬에 저장한다. (제 3 자 중개자가 필요 없는 대다수 자동화 된 분산 형 트랜잭션 모델.)4. Each transaction is encrypted and distributed to many individual computers (peer-to-peer), with each computer storing data locally. (Most automated decentralized transaction models that do not require third-party intermediaries.)

5. 네트워크 구성원은 개별 컴퓨터에 저장된 트랜잭션을 자동으로 확인한다. 5. Network members automatically check transactions stored on individual computers.

√에너지 거래를 위한 블록체인의 작동 순서. (도 1)√ Blockchain operation sequence for energy trading. (Figure 1)

1. 프로슈머와 컨슈머가 거래를 요청하면 거래 조건이 맞으면 거래에 동의한다.1. Prosumers and consumers request a transaction and agree to the transaction if the transaction conditions are met.

2. 요청 된 트랜잭션은 같은 기간 동안 이루어진 다른 트랜잭션과 결합되어 블록을 생성하고 노드로 알려진 컴퓨터들로 구성된 P2P 네트워크로 브로드캐스트 된다.2. The requested transaction is combined with other transactions made during the same period to create a block and broadcast to a peer-to-peer network of computers known as nodes.

3. 글로벌 네트워크에서는 알고리즘을 사용하여 거래 및 사용자 상태를 검증한다. 검증된 된 트랜잭션에는 암호 해독, 계약, 레코드 또는 기타 정보가 포함될 수 있다. 3. The global network uses algorithms to verify transaction and user status. Verified transactions may include cryptocurrency, contracts, records or other information.

4. 검증 된 블록은 이전에 검증된 다른 모든 거래와 결합되어 원장에 대한 새로운 데이터 블록을 만든다. 이는 블록이 지속적으로 증가 한다는 의미이다. 4. The verified block is combined with all other previously verified transactions to create a new data block for the ledger. This means that the block is constantly increasing.

5. 그런 다음 새 블록이 기존 블록체인에 영구적이며 변경 불가능한 방식으로 추가됨5. Then the new block is added to the existing blockchain in a permanent and immutable way

6. 트랜잭션이 완료6. Transaction completed

√에너지 거래를 위해 검증은 다음과 같은 단계를 거친다.√ For energy trading, verification goes through the following steps.

1. 개별 거래가 결합되어 블록을 형성한다.1. Individual transactions are combined to form a block.

2. 올바른 조합이 있는 경우 해시를 생성하는 알고리즘을 사용하여 각 블록에 포함 된 데이터를 확인한다.2. If there is a correct combination, check the data contained in each block using an algorithm that generates a hash.

3. 새로 생성된 블록은 지속적으로 증가하는 블록체인 끝에 추가된다. 3. Newly created blocks are added to the end of the ever-increasing blockchain.

4. 각 블록체인에 저장된 데이터 (모든 블록에 걸쳐 있음) 또한 지속적으로 검증된다.4. Data stored in each blockchain (which spans all blocks) is also continuously verified.

II. 에너지 거래를 위한 거래자간의 매칭 블록체인 생성II. Creating a matching blockchain between traders for energy trading

블록체인은 블록(Block)들이 해시값(Hash)으로 연결(Chain)되어 있고, 각 블록에는 복수의 정보가 들어있다. 블록들은 시간별로 정렬되어 있고 각각의 블록들은 이전 블록과 연결되어 있다. 만일 하나의 블록을 변경하게 되면 다른 블록의 내용도 전부 변하게 된다. 따라서 체인이 길어질수록 블록의 신뢰도가 증가하게 된다. 각 블록에 들어갈 수 있는 데이터는 금융 거래정보뿐만 아니라 무역거래정보, 에너지 사용정보 등 목적에 따라 다양하게 포함될 수 있다. In the blockchain, blocks are chained as a hash value, and each block contains a plurality of information. The blocks are sorted by time and each block is connected to the previous block. If one block is changed, the contents of the other block are also changed. Therefore, as the chain lengthens, the reliability of the block increases. Data that can be entered into each block may be variously included according to purposes such as trade transaction information and energy use information as well as financial transaction information.

본 연구에서는 전력 거래를 위한 블록체인을 구현한다. 본 거래를 위해서 프로슈머간에 경매알고리즘이 수행된다. 경매 알고리즘은 판매자가 경매 시간을 설정하여 그 시간 내에 경매가 이루어지는 것을 가정한다. 최적의 거래 기준은 주어진 시간에 최고 값을 제시한 컨슈머와 프로슈머 사이의 거래가 성사되는 것을 가정한다. 도 2는 에너지 거래 경매를 통한 블록체인 생성과정을 보여준다.In this study, we implement a blockchain for power transactions. For this transaction, auction algorithm is performed between prosumers. The auction algorithm assumes that the seller sets an auction time and an auction occurs within that time. The optimal trading criterion assumes that the trade between the consumer and the prosumer who presented the highest value at a given time. 2 shows a process of creating a blockchain through auctioning energy transactions.

경매를 통한 매칭은 다음과 같은 단계를 거친다 Matching through auction goes through the following steps

1. 판매를 위한 프로슈머의 잉여 전력량과 컨슈머의 수요 전력량이 결정되어 시장에 제시1. Prosumer's surplus power for sale and consumer's demand power are determined and presented to the market

2. 계약에 의해 통제되는 에너지 네트워크에서 제안한 거래의 전력량을 기반으로 프로슈머와 컨슈머간의 매칭 알고리즘 수행2. Perform matching algorithm between prosumer and consumer based on the power of the transaction proposed by the energy network controlled by the contract

3. 결정된 거래의 저를 기반으로 스마트 계약 체결3. Signing a smart contract based on the determined transaction me

III. UML을 이용한 블록체인 클래스 III. Blockchain class using UML

도 3의 클래스 탬플릿과 객체의 표현은 UML(Unified Modeling Language) 표기법을 사용하였다. 클래스 다이어그램은 프로그램언어와는 독립적이나 본 연구에서는 파이썬을 이용해 구현하였다. The UMT (Unified Modeling Language) notation was used for the representation of the class template and object in FIG. 3. The class diagram is independent of the programming language, but was implemented using Python in this study.

3.1 생성자 BlockChain()3.1 Constructor BlockChain()

생성시 다음의 변수들을 초기화 작업 진행한다. When creating, initialize the following variables.

chain : 모든 블록을 담을 list 변수를 초기화 한다. chain: Initializes the list variable to contain all blocks.

Transactions : 에너지 거래를 블록에 담기 위한 list 변수이다. Transactions: This is a list variable for storing energy transactions in a block.

create_block(Nonce = 1, PreviousHash = ‘0’) : 노드가 새로 생성될 때 Genesis 블록을 생성한다. create_block(Nonce = 1, PreviousHash = '0'): Create a Genesis block when a node is newly created.

nodes : 순서가 필요 없으며 주소만 넣을 set 변수로 선언, 한 노드에 하나의 주소가 정의된다. nodes: No order required, declared as a set variable to put only addresses, and one address is defined for one node.

3.2 함수 create_block (Nonce, PreviousHash): block3.2 function create_block (Nonce, PreviousHash): block

다음과 같이 구성된 Dictionary 타입의 블록 변수를 새로 생성한다. Create a new block variable of type Dictionary composed as follows.

block : index : 현재 체인 수 + 1 block: index: Current chain number + 1

CreatedTime : 현재 시간 CreatedTime: Current time

Hash : 현재 블록의 헤쉬값 Hash: Hash value of the current block

Nonce : Nonce값 Nonce: Nonce value

Previous Hash : 이전 블록의 헤쉬값 Previous Hash: The hash value of the previous block

Transactions : 에너지 거래 리스트가 담긴 Transactions list 변수를 추가 Transactions: Added Transactions list variable containing energy transaction list

생성 후 Hash() 함수를 호출하여 현재 블록의 헤쉬값을 정의하고 생성한 블록을 chain 변수에 추가하여 블록들을 연결한다. After creation, the Hash() function is called to define the hash value of the current block, and the created block is added to the chain variable to connect the blocks.

블록에 추가한 에너지 거래(Transactions 변수)들을 다시 초기화 하여 다시 사용한다. Reinitialize and reuse the energy transactions (Transactions variables) added to the block.

3.3 함수 get_previous_block ():chain3.3 Function get_previous_block ():chain

현재 블록의 이전 블록을 가져오기 위해서 체인의 마지막 위치의 블록을 불러온다. To get the previous block of the current block, the block at the end of the chain is called.

3.4 함수 Nonce_of_work(previous_Nonce): new_Nonce3.4 Function Nonce_of_work(previous_Nonce): new_Nonce

블록 생성단계에서 진행되는 작업증명 과정으로 new_Nonce와 check_Nonce를 선언해준다. 그 후 new_Nonce의 제곱에서 이전 블록의 Nonce(previous_Nonce)값의 제곱을 빼고 해당 값을 sha256(256비트로 구성된 64자리 문자열)형태로 변환한다. 해당 값을 Hash_operation 변수에 정의한다. New_Nonce and check_Nonce are declared as proof of work in the block creation phase. Subsequently, the square of New_Nonce is subtracted from the square of Nonce(previous_Nonce) value of the previous block, and the value is converted into sha256 (a 64-digit string composed of 256 bits). Define the value in Hash_operation variable.

Hash_operation 변수가 특정 조건(가장 앞 문자열 4자리 모두가 ‘0’)을 만족하면 new_Nonce값을 반환 해준다. If the Hash_operation variable satisfies a specific condition (all four digits of the first string are '0'), new_Nonce is returned.

3.5 함수 Hash(block): hash_value3.5 Function Hash(block): hash_value

Dictionary 타입의 block을 input값으로 받는다. 해당 block의 헤쉬값을 정의하기 위해 block의 데이터를 항상 같은 형식으로 정렬하고 encode작업을 진행하고 sha256형태로 변환하여 반환한다. It takes a dictionary type block as an input value. To define the hash value of the block, the data of the block is always sorted in the same format, the encoding process is performed, and it is converted to sha256 and returned.

3.6 함수 is_chain_valid(chain):Boolean3.6 Function is_chain_valid(chain):Boolean

consensus를 위한 체인의 유효성 검사로 체인을 구성하는 블록들이 문제가 없는지 확인하는 작업이다. 전체 블록 중 Genesis 블록(최초 블록)의 다음 블록부터 순서대로 검사를 진행한다. 검사를 진행하는 블록에서 가지고 있는 이전 헤쉬값과 실제 이전 블록의 헤쉬값을 비교하여 값이 일치하지 않다면 False값을 반환한다. 그리고 해당 블록과 이전 블록의 Nonce값을 활용하여 작업증명 과정을 다시 진행하여 설정해놓은 조건과 일치하지 않으면 False값을 반환한다. 모든 조건이 일치한다면 다음 블록의 검사를 진행한다. The validation of the chain for consensus is to make sure that the blocks that make up the chain are fine. Among all blocks, the check is performed in order from the next block of the Genesis block (the first block). It compares the previous hash value of the previous block with the actual previous block's hash value, and returns False if the values do not match. Then, using the nonce value of the corresponding block and the previous block, the process of proof of work is repeated, and if it does not match the set condition, a false value is returned. If all conditions are met, the next block is checked.

모든 블록의 검사가 정상적으로 진행됐다면 True값을 반환한다. Returns true if all blocks have been successfully inspected.

3.7 함수 add_energy_transaction(self, Sender, Receiver, UnitPriceperWatt, Amount, TotalPrice): 3.7 functions add_energy_transaction(self, Sender, Receiver, UnitPriceperWatt, Amount, TotalPrice):

Transactions변수에 에너지 거래 데이터를 추가하기 위한 함수이다. This function adds energy transaction data to the Transactions variable.

에너지 거래 데이터 = ‘Sender’ : prosumer Energy transaction data = ‘Sender’: prosumer

‘Receiver’ : consumer ‘Receiver’: consumer

‘Unitpriceperwatt’ : 와트당 단가 ‘Unitpriceperwatt’: Unit price per watt

‘Amount’: 전력량 ‘Amount’: Electricity

‘Totalprice’ : 총 가격 ( Amount * Unitpriceperwatt ) 'Totalprice': Total price (Amount * Unitpriceperwatt)

flask 함수를 통해서 입력받은 input값들을 Dictionary 타입으로 묶어 Transactions list변수에 추가해준다. The input values received through the flask function are grouped into a Dictionary type and added to the Transactions list variable.

마지막 블록(체인의 마지막)의 인덱스값을 불러와 현재 에너지 거래가 몇 번째 블록에 추가되는지 기록을 위해 추가되는 블록의 인덱스값을 반환한다. It retrieves the index value of the last block (the end of the chain) and returns the index value of the block added to record how many blocks the current energy transaction is added to.

3.8 함수 add_node(self, address):3.8 Function add_node(self, address):

네트워크에 노드를 추가하기 위한 함수이다. This is a function for adding a node to the network.

노드의 주소를 입력받아 주소를 parse하고 해당 노드를 네트워크에 추가한다. It receives the node's address, parses the address, and adds the node to the network.

http://127.0.0.1:5000/ => ‘127.0.0.1:5000’와 같이 변경하여 추가한다. http://127.0.0.1:5000/ => Change it to '127.0.0.1:5000' and add it.

3.9 함수 replace_energy_chain():Boolean3.9 Function replace_energy_chain():Boolean

네트워크에 있는 모든 노드는 항상 같은 체인을 유지해야하며 어떤 체인이 네트워크에 있는 가장 긴 체인보다 작은가를 검사하여 이를 대체한다. Every node in the network should always keep the same chain, and it checks which chain is smaller than the longest chain in the network and replaces it.

network 변수에 모든 노드를 정의한다. 모든 노드의 체인이 유효(is_chain_valid)하다면 network 변수에 정의된 각 노드의 체인길이와 자신의 체인길이를 비교하여 자신보다 긴 체인이 존재할 경우 자신의 체인을 가장 긴 체인으로 대체하고 True값을 반환하고, 자신의 체인이 제일 길다면 False값을 반환한다. Define all nodes in the network variable. If the chain of all nodes is valid (is_chain_valid), compare the chain length of each node defined in the network variable with its own chain length, and if there is a chain longer than itself, replace the chain with the longest chain and return True. , If its chain is the longest, it returns False.

IV. 플라스크 상에서 웹 어플리케이션 실행IV. Running a web application on Flask

Flask : 플라스크란 WSGI 마이크로프레임워크로써 최소한의 기능만을 제공하여 아주 유연하게 어플리케이션 작성이 가능하다.Flask: Flask is a WSGI microframework that provides minimal functionality and allows for very flexible application creation.

app = Flask(__name__) : Flask class의 인스턴스를 생성한다. 모듈 또는 패키지 단일 모듈로 사용을 하므로 __name__을 사용해야 한다.app = Flask(__name__): Create an instance of Flask class. Because it is used as a single module or package, __name__ must be used.

from flask import Flask, jsonify, request :from flask import Flask, jsonify, request:

jsonify : Flask에서의 JSON 유틸리티 함수로써 JSON 타입의 HTTP Response를 생성하기 위하여 Import한다.jsonify: This is a JSON utility function in Flask, and is imported to create a JSON-type HTTP Response.

request : HTTP 통신을 위한 라이브러리로 유입 요청 데이터에 접근하기 위하여 Import한다.request: Imported to access incoming request data to the library for HTTP communication.

@app.route() : URL 규칙을 받아 해당하는 규칙의 URL로 요청이 들어온 경우 등록한 함수를 실행한다.@app.route(): Receives a URL rule and executes the registered function when a request comes in to the URL of the corresponding rule.

4.1 블록 생성 : mine_energy_block()4.1 Block creation: mine_energy_block()

새로운 블록 한 개를 채굴하는 함수이다. Transactions 변수가 비어있다면(에너지 거래가 이루어지지 않았다면) 'No Transactions entered' 메시지를 반환한다. 새로 블록을 생성하고 연결할 블록(현재 체인의 마지막 블록)을 가져온다. 새로 생성된 블록의 작업증명(Nonce)은 이전 블록의 Nonce값을 활용하여 Nonce_of_work 함수로 반환된 값을 사용한다. 그 후 create_block으로 증명 값과 이전 블록의 해쉬 값을 포함하여 블록을 하나 생성한다. This is a function that mines a new block. If the Transactions variable is empty (if no energy transaction has been made), the message'No Transactions entered' is returned. Create a new block and get the block to connect (the last block in the current chain). The proof of work of a newly created block (Nonce) uses the value returned by the Nonce_of_work function by utilizing the value of Nonce of the previous block. Then, create a block with create_block including the hash value of the previous block and the proof value.

response = Index : 현재 블록의 index 값response = Index: index value of the current block

CreatedTime : 현재 시간 CreatedTime: Current time

Nonce : 현재 블록의 작업증명 값 Nonce: Work proof value of the current block

previous_hash : 이전 블록의 헤쉬값 previous_hash: Hash value of previous block

Hash : 현재 블록의 헤쉬값 Hash: Hash value of the current block

Transactions : 현재 블록에 transactions 변수 Transactions: transactions variable in the current block

return jsonify(response),201 : response의 값을 JSON형식으로 반환한다. 반환값의 상태 코드는 도 5에서 보여주고 있다.return jsonify(response),201: Returns the value of response in JSON format. The status code of the return value is shown in FIG. 5.

4.2 모든 블록 가져오기 위한 함수들 : get_chain(), get_value(), 4.2 Functions for fetching all blocks: get_chain(), get_value(),

·get_chain()·Get_chain()

실행하는 노드의 현재 체인의 데이터 값과 길이를 확인할 수 있는 함수이다. This function checks the data value and length of the current chain of the executing node.

response = chain : 현재 노드의 chainresponse = chain: chain of the current node

length : 체인의 블록 수 length: Number of blocks in the chain

return jsonify(response), 200 값을 반환한다.return jsonify(response), returns 200

·get_value()·Get_value()

불러오는 데이터의 형태가 json형태이기 때문에 PHP환경에서 각 데이터의 KEY값의 접근할 수 있도록 변환해서 반환해주는 함수이다. This is a function that converts and returns the KEY value of each data in the PHP environment because the data type to be loaded is json.

4.3 블록체인 유효성 검사를 위한 함수 : is_valid()4.3 Blockchain validation function: is_valid()

실행하는 노드의 체인이 유효한가를 검사하여 이에 해당하는 메시지를 반환해준다. It checks whether the chain of the executing node is valid and returns the corresponding message.

실행되는 함수 : is_chain_valid() Function executed: is_chain_valid()

return 값이 참이라면 'message': '블록체인이 유효합니다.' 값을 response 변수에 저장해주며 If the return value is true,'message':'Blockchain is valid.' Store the value in the response variable

return 값이 거짓이라면 'message': '현재 블록체인에 문제가 있습니다' 값을 response 변수에 저장해준다. If the return value is false, the value of'message':'There is a problem with the current blockchain' is stored in the response variable.

return jsonify(response), 200 값을 반환한다.return jsonify(response), returns 200

4.4 블록체인에 에너지 거래 추가하기 위한 함수들 : add_energy_transaction(), add_energy_transaction_get()4.4 Functions for adding energy transactions to the blockchain: add_energy_transaction(), add_energy_transaction_get()

에너지 거래가 이루어지면 해당 거래의 데이터값을 에너지 거래 데이터 변수에 받아서 블록에 추가해준다. When an energy transaction is made, the data value of the transaction is received in the energy transaction data variable and added to the block.

에너지 거래 데이터 = ‘Sender’ : 프로슈머 Energy transaction data = ‘Sender’: Prosumer

‘Receiver’ : 컨슈머 ‘Receiver’: Consumer

‘Unitpriceperwatt’ : 와트당 단가 ‘Unitpriceperwatt’: Unit price per watt

‘Amount’: 전력량 ‘Amount’: Electricity

‘Totalprice’ : 총 가격 ( Amount * Unitpriceperwatt ) 'Totalprice': Total price (Amount * Unitpriceperwatt)

실행되는 함수 : add_energy_transaction() Function executed: add_energy_transaction()

에너지 거래에 사용되는 변수 중에 정의되지 않은 값이 있다면 '거래를 위한 어떤 값(들)이 빠져 있습니다. 점검해보시기 바랍니다.' 400 값을 반환한다. If any variable used for energy trading has an undefined value,'the value(s) for the transaction is missing. Please check it.' Returns a value of 400.

에너지 거래에 사용되는 변수에 모든 값이 정의 되어있다면 add_energy_transaction()함수를 실행 시키고 'message': '이 거래는 블록에 추가 됩니다.' + str(Index) 값을 response 변수에 선언해준다. If all values are defined in the variables used for energy trading, execute the add_energy_transaction() function and'message':'This transaction is added to the block.' + The str(Index) value is declared in the response variable.

return jsonify(response), 201 값을 반환한다.return jsonify(response), 201.

4.5 체인을 초기상태로 변환 해주는 함수들 : self_init(), all_self_init()4.5 Functions that convert the chain to the initial state: self_init(), all_self_init()

self_init() self_init()

실행되는 노드의 체인상태를 초기상태로 만드는 함수이다. This function makes the chain state of the executed node to the initial state.

실행되는 함수 : selfinit() Function executed: selfinit()

response = chain : 현재 노드의 chainresponse = chain: chain of the current node

length : 체인의 블록 수 length: Number of blocks in the chain

return jsonify(response), 200 값을 반환한다.return jsonify(response), returns 200

all_self_init() all_self_init()

네트워크에 존재하는 모든 노드의 체인을 초기상태로 만드는 함수이다. This function initializes the chain of all nodes in the network to the initial state.

실행되는 함수 : self_init() Function executed: self_init()

V. 블록체인의 탈 중앙화하고 참여하는 모든 노드들의 블록을 같게 만드는 방법V. How to decentralize the blockchain and make the blocks of all participating nodes the same

5.1 새로운 노드 연결 : connect_node()5.1 New node connection: connect_node()

실행되는 노드에 새로운 노드를 연결하며 각 노드간의 네트워크를 구성할 수 있도록 해주는 함수이다. It is a function that connects a new node to the node to be executed and configures the network between each node.

실행되는 함수 : add_node() Function executed: add_node()

새로운 노드의 주소값을 입력받고 노드를 추가하여 네트워크 변수에 추가해준다. The address value of the new node is entered, and the node is added to the network variable.

입력값이 존재하지 않다면 "No node", 400 값을 반환한다. If the input value does not exist, "No node", 400 is returned.

모든 노드가 정상적으로 처리되었다면 If all nodes were processed normally

response = 'message': '모든 노드들이 이제 연결되었습니다.' response ='message':'All nodes are now connected.'

total_nodes : 현재 노드와 연결되어 있는 노드들 total_nodes: Nodes currently connected to the node

return jsonify(response), 201 값을 반환한다. return jsonify(response), 201.

5.2 필요시 가장 긴 체인으로 체인을 대체 : replace_energy_chain()5.2 Replace the chain with the longest chain if necessary: replace_energy_chain()

실행되는 노드에서 네트워크상에서 가장 긴 노드를 판별하여 이에 해당하는 작업을 처리해주는 함수이다. This function determines the longest node on the network from the node being executed and processes the corresponding task.

실행되는 함수 : replace_energy_chain() Function executed: replace_energy_chain()

return 값이 참이라면If return value is true

response = 'message': '현재 노드에는 다른 노드와 같지 않습니다. 유효한 노드의 블록체인으로 대체합니다.' response ='message':'The current node is not the same as any other node. Replace it with a valid node's blockchain.'

new_chain : 대체된 체인값의 해당하는 값을 response에 선언해준다. new_chain: Declares the corresponding value of the replaced chain value in the response.

return 값이 거짓이라면 If return value is false

response = 'message': '블록체인이 유효하게 유지되고 있습니다.' response ='message':'Blockchain remains valid.'

actual_chain: 자신의 체인값의 해당하는 값을 response에 선언해준다. actual_chain: Declares the corresponding value of your chain value in response.

return jsonify(response), 200 해당 값을 반환해준다. return jsonify(response), 200 Returns the relevant value.

Claims (1)

블록체인 기반 전력거래 플랫폼을 통해 실시간으로 최적의 프로슈머와 소비자를 매칭하고 P2P(peer to peer) 거래 할 수 있도록 하는 클라우드 기반 소규모 에너지 거래.A cloud-based small-scale energy transaction that enables optimal peer-to-peer (P2P) transactions by matching the optimal prosumers and consumers in real time through a blockchain-based power trading platform.
KR1020180152328A 2018-11-30 2018-11-30 Microgrid energy transaction based on cloud KR20200065655A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020180152328A KR20200065655A (en) 2018-11-30 2018-11-30 Microgrid energy transaction based on cloud

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020180152328A KR20200065655A (en) 2018-11-30 2018-11-30 Microgrid energy transaction based on cloud

Publications (1)

Publication Number Publication Date
KR20200065655A true KR20200065655A (en) 2020-06-09

Family

ID=71082968

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020180152328A KR20200065655A (en) 2018-11-30 2018-11-30 Microgrid energy transaction based on cloud

Country Status (1)

Country Link
KR (1) KR20200065655A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102410052B1 (en) 2021-02-17 2022-06-16 주식회사 인코어드피앤피 Apparatus and method for managing cloud-based microgrid distributed power supply

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102410052B1 (en) 2021-02-17 2022-06-16 주식회사 인코어드피앤피 Apparatus and method for managing cloud-based microgrid distributed power supply

Similar Documents

Publication Publication Date Title
Westerkamp et al. Blockchain-based supply chain traceability: Token recipes model manufacturing processes
Westerkamp et al. Tracing manufacturing processes using blockchain-based token compositions
US10937111B2 (en) Managing energy purchase agreements on a blockchain
TWI768163B (en) Method and device for generating smart contracts
EP3540662A1 (en) Computer implemented method for supply chain management and provenance in a data processing network
AU2022291462A1 (en) System and Method for Controlling Asset-Related Actions via a Blockchain
Wright et al. Sustainable blockchain-enabled services: Smart contracts
Braghin et al. Designing smart-contract based auctions
Reimers et al. Integration of blockchain and internet of things in a car supply chain
Kaynak et al. Cloud manufacturing architecture based on public blockchain technology
KR20220136998A (en) Blockchain-based green certificate transaction system
CN112686671A (en) Intelligent contract deployment method, device, equipment and medium based on block chain
CN112581197A (en) Bill number distribution method and device based on block chain and electronic equipment
CN112035879B (en) Information processing method and system for improving confidentiality of automatic logistics of cell
Dzobo et al. Proposed framework for blockchain technology in a decentralised energy network
EP3736760A1 (en) Automated transaction protocol linking renewable energy generation assets to energy power consumers applying distributed digital ledger technology and iot energy meters
CN111488616A (en) Method and device for realizing preplan machine of service data block chain
Di Silvestre et al. An energy blockchain, a use case on tendermint
US20240005409A1 (en) Systems, methods, and storage media for managing digital liquidity tokens in a distributed ledger platform
KR20200065655A (en) Microgrid energy transaction based on cloud
Dietrich et al. Concept for a token-based blockchain architecture for mapping manufacturing processes of products with changeable configurations
Pourheidari et al. A case study of execution of untrusted business process on permissioned blockchain
CN111882436B (en) Data processing method, device and equipment based on block chain
CN109472661A (en) Data processing method, system and computer equipment based on electronic contract
CN114170006A (en) Information data acquisition method, device, equipment and medium based on state machine

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E601 Decision to refuse application