I hereby claim:
- I am mgraczyk on github.
- I am mgraczyk (https://keybase.io/mgraczyk) on keybase.
- I have a public key ASCXHJBSlHw5mSW5e3DkRc5b3u0lrX_rLTER3xi26FZoLgo
To claim this, I am signing this object:
| import asyncio as asyncio # keep | |
| import enum | |
| import random | |
| from typing import Callable | |
| from typing import Literal | |
| from typing import NotRequired | |
| from typing import TypedDict | |
| import lxml.etree |
I hereby claim:
To claim this, I am signing this object:
| // DO NOT USE: Incomplete example code. | |
| contract PlotNFT is Ownable { | |
| address target; | |
| uint256 targetMinBlock; | |
| constructor(address _target) public { | |
| target = _target; | |
| targetMinBlock = 0; | |
| } | |
| #!/bin/env python3 | |
| import sys | |
| try: | |
| import plyvel | |
| except ImportError: | |
| print("Install plyvel: python3 -m pip install plyvel") | |
| sys.exit(1) | |
| def usage(): |
| import numpy as np | |
| from matplotlib import pyplot as plt | |
| def make_Av(N): | |
| a = 1 - 0.5 * 0.75 | |
| b = 0.5 * 0.25 | |
| A = np.zeros((2 * N + 2, 2 * N + 2)) |
| import asyncio | |
| num_times = 0 | |
| async def one_time_setup(): | |
| global num_times | |
| num_times += 1 | |
| print("doing setup") | |
| await asyncio.sleep(1) |
| func (n *Node) IsAccepted(tx *Transaction) bool { | |
| mutex.RLock() | |
| defer mutex.RUnlock() | |
| committed := false | |
| for _, parent := range tx.Body.GetParents() { | |
| parent := n.Transactions[parent] | |
| committed = committed && n.IsAccepted(parent) | |
| } | |
| set := n.Conflicts[tx.Body.Utxo] | |
| // [OT] safe early commitment. |
| // ... update the preference for ancestors | |
| // [OT] This only loops over parents, not ancestors | |
| for _, parentId := range tx.Body.Parents { | |
| mutex.RLock() | |
| parent := n.Transactions[parentId] | |
| conflicts := n.Conflicts[parent.Body.Utxo] | |
| mutex.RUnlock() | |
| parentScore, presentScore := n.Confidence(parent), n.Confidence(conflicts.Preferred) | |
| if parentScore > presentScore { | |
| conflicts.Preferred = parent |
| func QueryEvents(n *Node, rpc RPC) { | |
| // [OT] Line 2 with modified condition | |
| for id, tx := range n.Unqueried() { | |
| // [OT] Check that the transactions parents are known | |
| // In a real implementation, undigestible txns | |
| // would eventually need to be pruned. | |
| if !n.IsDigestable(tx) { | |
| continue | |
| } | |
| // [OT] Lines 4-5 |
| func (n *Node) IsStronglyPreferred(tx *Transaction) bool { | |
| mutex.RLock() | |
| defer mutex.RUnlock() | |
| stronglyPreferred := true | |
| parents := // ... make map of parent ids | |
| for len(parents) != 0 { | |
| for parentId := range parents { | |
| // [OT] stronglyPreferred could be memoized here for efficiency | |
| // This is a downside of using protocol buffers for state. | |
| // Additional in-memory state can't be stored naturally because |