This file contains 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
<div class="select__dropdown> | |
<span class="select__value"></span> | |
<ul class="select__optionlist"> | |
<li class="select__option">Option 1</li> | |
<li class="select__option">Option 2</li> | |
<li class="select__option">Option 3</li> | |
</ul> | |
</div> |
This file contains 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
<style lang="scss" scoped> | |
$background-color: #fff; | |
$border-color: #101010; | |
$border-inactive-color: #606060; | |
$border-radius: 5px; | |
$item-hover-color: #f5f5f5; | |
$item-selected-color: rgba(0, 0, 0, .25); | |
*, | |
*:before, |
This file contains 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
<div> <!-- Container --> | |
<span></span> <!-- Selected value --> | |
<ul> | |
<li></li> <!-- Options --> | |
<li></li> | |
<li></li> | |
</ul> | |
</div> |
This file contains 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 HttpHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
if self.path == '/blocks': | |
self.set_response_headers(200) | |
self.wfile.write(bytes(json.dumps(chain, default=jdefault), "utf8")) | |
elif self.path == '/peers': | |
self.set_response_headers(200) | |
self.wfile.write(bytes(json.dumps(peers), "utf8")) | |
else: | |
self.set_response_headers(400, "plain/text") |
This file contains 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
def is_block_valid(next_block, last_block): | |
if last_block.index + 1 != int(new_block["index"]): | |
return False | |
if last_block.hash != new_block["prev_hash"]: | |
return False | |
block_val = str(new_block["index"]) + str(new_block["nonce"]) + new_block["prev_hash"] + \ | |
str(new_block["timestamp"]) + new_block["data"] | |
if calculate_hash(block_val) != new_block["hash"]: | |
return False |
This file contains 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
def mine_genesis_block (): | |
timestamp = time.time() | |
return mine_block(0, "0", timestamp, "Genisis Block") | |
chain = [mine_genesis_block()] |
This file contains 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
def mine_genesis_block (): | |
timestamp = time.time() | |
return mine_block(0, "0", timestamp, "Genisis Block") |
This file contains 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
def add_block (data): | |
prev_block = get_last_block() | |
timestamp = time.time() | |
new_block = mine_block(prev_block.index + 1, prev_block.hash, timestamp, data) | |
return new_block |
This file contains 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 | |
difficulty = 4 | |
pattern = '0000' | |
def calculate_hash(data_to_hash): | |
return hashlib.sha256(data_to_hash.encode("utf-8")).hexdigest() | |
def mine_block(index, prev_hash, timestamp, data): | |
for nonce in range(1, maxNonce): |
This file contains 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 | |
def calculate_hash(index, nonce, timestamp, data, prev_hash): | |
block_val = str(index) + str(nonce) + prev_hash + str(timestamp) + data | |
return hashlib.sha256(block_val.encode("utf-8")).hexdigest() |