This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| import json | |
| from time import time | |
| from uuid import uuid4 | |
| from flask import Flask, jsonify, request | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| import json | |
| from textwrap import dedent | |
| from time import time | |
| from uuid import uuid4 | |
| from flask import Flask, jsonify, request | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| import json | |
| from textwrap import dedent | |
| from time import time | |
| from uuid import uuid4 | |
| from flask import Flask | |
| class Blockchain(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| import json | |
| from time import time | |
| from uuid import uuid4 | |
| class Blockchain(object): | |
| ... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from hashlib import sha256 | |
| x = 5 | |
| y = 0 | |
| while sha256(f'{x*y}'.encode()).hexdigest()[-1] != "0": | |
| y += 1 | |
| print(f'The solution is y = {y}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| impot json | |
| from time import time | |
| class Blockchain(object): | |
| def __init__(self): | |
| self.current_transactions = [] | |
| self.chain = [] | |
| # ์๋ก์ด ์ ๋ค์์ค ๋ธ๋ก ๋ง๋ค๊ธฐ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Blockchain(object): | |
| ... | |
| def new_transaction(self, sender, recipient, amount): | |
| """ | |
| ์๋ก์ด ๊ฑฐ๋๋ ๋ค์์ผ๋ก ์ฑ๊ตด๋ ๋ธ๋ก์ ํฌํจ๋๊ฒ ๋๋ค. ๊ฑฐ๋๋ 3๊ฐ์ ์ธ์๋ก ๊ตฌ์ฑ๋์ด ์๋ค. | |
| sender์ recipient๋ string์ผ๋ก ๊ฐ๊ฐ ์์ ์์ ์ก์ ์์ ์ฃผ์์ด๋ค. | |
| amount๋ int๋ก ์ ์ก๋๋ ์์ ์๋ฏธํ๋ค. return์ ํด๋น ๊ฑฐ๋๊ฐ ์ํด์ง ๋ธ๋ก์ ์ซ์๋ฅผ ์๋ฏธํ๋ค. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| block = { | |
| 'index': 1, | |
| 'timestamp': 1506057125.900785, | |
| 'transactions': [ | |
| { | |
| 'sender': "8527147fe1f5426f9dd545de4b27ee00", | |
| 'recipient': "a77f5cdfa2934df3954a5c7c7da5df1f", | |
| 'amount': 5, | |
| } | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Blockchain(object): | |
| def __init__(self): | |
| self.chain=[] | |
| self.current_transactions=[] | |
| def new_block(self): | |
| # ์๋ก์ด ๋ธ๋ก์ ์์ฑํ๊ณ ์ฒด์ธ์ ๋ฃ๋๋ค | |
| pass | |
| @staticmethod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // cli.go | |
| // send ๋ช ๋ น์ด๋ฅผ ๊ตฌํํ ๊ฒ | |
| func (cli *CLI) send(from, to string, amount int) { | |
| bc := NewBlockchain(from) | |
| defer bc.db.Close() | |
| tx := NewUTXOTransaction(from, to, amount, bc) | |
| bc.MineBlock([]*Transaction{tx}) | |
| fmt.Println("Success!") |
NewerOlder