-
Create a database Using createdb in Postgres.
-
Establish a connection to the database We can connect to a Postgres server from a Python web server using pyscopg2 with psycopg2.connect().
-
Define and create your data schema Execute CREATE TABLE commands to create the tables and define the schema (attributes, data types, etc) that will define what data gets housed for our web app.
-
Seed the database with initial data
import React, { useState } from 'react'; | |
import ReactDOM from 'react-dom'; | |
function Counter() { | |
const [count, setCount] = useState(0); | |
function increment(){ | |
setCount(count + 1) | |
} | |
return ( |
class Greeter extends React.Component { | |
render() { | |
const {first, last} = this.props; | |
return <h1>Hello, {first} {last}</h1>; | |
} | |
} | |
ReactDOM.createRoot(document.getElementById("root")).render( | |
<Greeter first="Srini" last="Kata" /> | |
); |
// when you navigate to htlc.me for the first time it randomly assigns a wallet id | |
//this code return a wallet id using the crypto method ( uses UUID (universally unique identifier) concept which i don't really understand | |
App.uuid = (args) => { | |
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => | |
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) | |
); | |
}; |
function generateAdvice() { | |
fetch("https://api.adviceslip.com/advice", { cache: "no-cache" }) | |
.then((response) => response.json()) | |
.then((response) => { | |
let data = response.slip; | |
let dataId = data.id; | |
let dataAdvice = data.advice; | |
adviceId.innerHTML = `advice # ${dataId}`; |
- JSX represents objects
- JSX is an exoression too
The function signature is: createElement(type, props, children)
.
A React element is essentially a JavaScript object containing a type
and props
object.
- React can't render into the body node, but we can choose any node within the body
- Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.
https://decentralizedthoughts.github.io/2020-12-22-what-is-a-merkle-tree/
A very simple way to think of a Merkle hash tree with n leaves is as a collision-resistant hash function 𝖬𝖧𝖳 that takes n inputs11 and ouputs a 2λ-bit hash, a.k.a. the Merkle root hash. More formally, the Merkle hash function is defined as:
𝖬𝖧𝖳:({0,1}∗)n→{0,1}2λ
And the Merkle root of some input x =(x1,…,xn) is denoted by:
h=𝖬𝖧𝖳(x1,…,xn)(5)
Formally, we can define a hash function as a mathematical function H:{0,1}∗↦{0,1}256. We use H(x)=y to denote that y is the output of H on input x.
A hash function is a random oracle: it takes an arbitrarily-sized input x, flips 256 coins y=⟨y1,y2,…,y256⟩, “remembers” x↦y, and from now on always returns y (i.e., 256 bits) on input x.
- Download integrity
- proof-of-work
- committment
# Set the best block hash here: | |
assumevalid= | |
# Run as a daemon mode without an interactive shell | |
daemon=1 | |
# Set the data directory to the storage directory | |
# Set the number of megabytes of RAM to use, set to like 50% of available memory |
def setup_network(self): | |
"""Setup the test network topology""" | |
def run_test(self): | |
"""Main test logic""" | |
self.log.info("Starting test!") | |
"""Let the user know the test has started""" | |
self.sync_all(self.nodes) | |
"""Sync all nodes for the test (1,2)""" |