Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# For each staked validator, get the release version
# command to call miner of the desired validator to use
MINER=./_build/validator/rel/miner/bin/miner
VALS=$(${MINER} ledger validators --format csv -v | awk -F, '$7 == "staked" {print $2}')
${MINER} ledger validators --format csv -v | awk -F, '$7 == "staked" {print $2}' | xargs -P 0 -I{} ${MINER} peer connect /p2p/{}

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@Vagabond
Vagabond / main.md
Created February 8, 2018 19:52
RFC for modernizing Riak repos for OTP20/rebar3

Here's my proposal on the general steps to modernize Riak's repos to work with OTP20 and rebar3:

  • Replace bundled copy of rebar with a chosen version of rebar3
  • Add any required rebar3 plugins (eqc, port compiler, etc)
  • Rework any EQC tests to work with the rebar3 EQC plugin and not be eunit tests
  • Remove tools.mk and Makefile if present
  • Add a generic Makefile which has targets for compile/dialyzer/eunit/common_test/xref/coverage/eqc and a 'check' meta-target
  • We can also add Travis/coveralls support (example: helium/erlang-libp2p#33 (comment))
  • Commit the rebar3 rebar.lock file - this replaces the old lock-deps rebar2 plugin
-module(hashmap_eqc).
%% include some quickcheck headers
-include_lib("eqc/include/eqc.hrl").
-include_lib("eqc/include/eqc_statem.hrl").
%% include the eqc-c generated header
-include("hashmap.hrl").
%% function to initialize the model state
-: 1:#include "utils/hashmap.h"
-: 2:#include <stdint.h>
-: 3:#include <stdlib.h>
-: 4:#include <string.h>
-: 5:#include <math.h>
-: 6:
-: 7:#define FNV_32_PRIME ((uint32_t)0x01000193)
-: 8:#define FNV1_32_INIT ((uint32_t)2166136261)
-: 9:#define TINY_MASK(x) (((uint32_t)1<<(x))-1)
-: 10:#define BUCKETS_SIZE(x) (pow(2,(x)))
hashmap_iter_delete_pre(S) ->
S#state.hashmap /= undefined.
hashmap_iter_delete_args(S = #state{map=Map}) when length(Map) > 0 ->
[S#state.hashmap,
eqc_gen:oneof([eqc_gen:elements(element(1, lists:unzip(S#state.map))),
?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)])];
hashmap_iter_delete_args(S) ->
[S#state.hashmap, ?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)].
hashmap_replace_pre(S) ->
S#state.hashmap /= undefined andalso length(S#state.map) > 0.
hashmap_replace_args(S) ->
{Keys, Values} = lists:unzip(S#state.map),
[S#state.hashmap, eqc_gen:oneof(Keys),
?SUCHTHAT(X2, eqc_gen:list(eqc_gen:char()), length(X2) > 0 andalso not lists:member(X2, Values))].
hashmap_replace(Hashmap, Key, Value) ->
KeyStr = eqc_c:create_string(Key),
hashmap_compare_pre(S) ->
S#state.hashmap /= undefined.
hashmap_compare_args(S) ->
[S#state.hashmap].
hashmap_compare(Hashmap) ->
Iter = eqc_c:alloc({struct, iterator_t}),
hashmap:hashmap_iter_begin(Hashmap, Iter),
R = dump_hash(Iter, []),
hashmap_delete_pre(S) ->
S#state.hashmap /= undefined.
hashmap_delete_args(S = #state{map=Map}) when length(Map) > 0 ->
[S#state.hashmap,
eqc_gen:oneof([eqc_gen:elements(element(1, lists:unzip(S#state.map))),
?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)])];
hashmap_delete_args(S) ->
[S#state.hashmap, ?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)].
hashmap_clear_pre(S) ->
S#state.hashmap /= undefined.
hashmap_clear_args(S) ->
[S#state.hashmap].
hashmap_clear(Hashmap) ->
hashmap:hashmap_clear(Hashmap).
hashmap_clear_next(S, _R, [_]) ->