Skip to content

Instantly share code, notes, and snippets.

View matheusd's full-sized avatar

Matheus Degiovani matheusd

View GitHub Profile
type runner struct {}
func (r *runner) run(ctx context.Context) error {
g, gctx := errgroup.WithContext(ctx)
// loads of goroutines
g.Go(func() error {
// something something, then
return context.Cause(gctx)
})
return g.Wait()
package main
import (
"math/bits"
"math/rand/v2"
"slices"
"sort"
"testing"
)

3PH With Multiple Pipeline Steps

This is a 3PH scenario where there are pipelined calls that were made before the determination that the capability was in a third party and should be forwarded by the broker (Bob) to the final server.

The Scenario

  • Vat A (Alice/Client): Our client. She wants to get a capability and immediately use it.
  • Vat B (Bob/Intermediary): A service that acts as a factory or broker. It doesn't host the final capability itself.
  • Vat C (Carol/Server): The service that actually owns and hosts the final resource.
@matheusd
matheusd / .gitconfig
Created October 13, 2020 11:39
git aliases
[alias]
l = !"git lshort --graph"
lg = !"git lg1"
lg1 = !"git lg1-specific --all"
lg2 = !"git lg2-specific --all"
lg3 = !"git lg3-specific --all"
cp = cherry-pick
cpc = cherry-pick --continue
st = status
package main
import (
"sync"
)
func Highway(asyncProcessor EventProcessor, numWorkers int, inputC chan Event) chan HydratedEvent {
outputC := make(chan HydratedEvent, 0)
type worker struct {
@matheusd
matheusd / gist:02453f59e9d9da731eff154733d87b6c
Last active July 8, 2020 18:25
A script to check a dcrlnd commit if it's reasonably sane. Useful to check a range of commits by using a `git rebase [target] --exec ./checkcommit.py --modtidy --test --rpc --lint --showcommit --nofooter`
#!/bin/python3
import sys
import subprocess
from os import path
from functools import reduce
class bcolors:
RED = '\033[31m'
BLUE = '\033[34m'
@matheusd
matheusd / pre-push
Created July 8, 2020 18:23
Pre-push hook to verify all commits were gpg signed
#!/bin/sh
# Somewhat adapted from the same hook and from
# https://gist.github.com/kotnik/ef3a62316aa5e8e788a6e4365cb41878
#
# Uses my git lshort alias on error.
remote="$1"
url="$2"
Props to Pierre-Marie Padiou via https://github.com/lightningnetwork/lightning-rfc/issues/553#issuecomment-455641943
+------------+
| funding tx |
+------------+
|
| +-------------+
\--------| commit tx B |
+-------------+
| | | |
@matheusd
matheusd / spv.tmux
Created October 6, 2018 12:19
Tmux automation for setting up an spv wallet
#!/bin/sh
# Tmux setup for running an spv wallet. This creates two wallets (connected to
# the same master node): one using regular RPC mode with the ticketbuyer and
# voting enabled and a second one with SPV enabled. It receives some coins
# after block 32.
#
# The spv wallet is created in the "spv" dir.
set -e
$ ./dcrctl.sh getblockchaininfo
{
"chain": "mainnet",
"blocks": 279436,
"headers": 279436,
"bestblockhash": "00000000000000004d1ca3ac7aab36e4857f97e78876fc405a1986e99bc87b5a",
"difficulty": 419481279,
"verificationprogress": 0.9962138767477843,
"chainwork": "0x8836d4f2be1b9cdeff59",
"initialblockdownload": true,