Skip to content

Instantly share code, notes, and snippets.

View shawntabrizi's full-sized avatar

Shawn Tabrizi shawntabrizi

View GitHub Profile
@shawntabrizi
shawntabrizi / demo.rs
Last active February 11, 2019 12:12
Gav Demo Runtime from Web3 Summit
// initialise with:
// post({sender: runtime.indices.ss58Decode('F7Gh'), call: calls.demo.setPayment(1000)}).tie(console.log)
use parity_codec::Encode;
use srml_support::{StorageValue, dispatch::Result, decl_module, decl_storage};
use runtime_primitives::traits::Hash;
use {balances, system::{self, ensure_signed}};
pub trait Trait: balances::Trait {}
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result};
use system::ensure_signed;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
type U8 = [u8; 1];
decl_storage! {
use support::{decl_module, dispatch::Result,
traits::{Currency, ExistenceRequirement, WithdrawReason}};
use system::ensure_signed;
// v1.0 branch
// use runtime_primitives::traits::As;
pub trait Trait: balances::Trait {}
decl_module! {
@shawntabrizi
shawntabrizi / adder_module.rs
Created June 21, 2019 10:19
Simple adder for Substrate
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result, ensure, StorageMap};
use system::ensure_signed;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
decl_storage! {
trait Store for Module<T: Trait> as calculator {
FinalResult: u64;
@shawntabrizi
shawntabrizi / enum_module.rs
Created July 10, 2019 18:00
Substrate Enum
use support::{decl_module, decl_storage, StorageValue, dispatch::Result};
use system::ensure_signed;
use parity_codec::{ Encode, Decode };
#[derive(Encode, Decode, Clone, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Choices {
None,
One,
Two,
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result};
use system::ensure_signed;
use rstd::prelude::*;
use rstd::collections::btree_set::BTreeSet;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
decl_storage! {
@shawntabrizi
shawntabrizi / customSpecRaw.json
Last active September 13, 2019 08:37
Geneva Workshop
{
"name": "Local Testnet",
"id": "local_testnet",
"bootNodes": [
"/ip4/127.0.0.1/tcp/30333/p2p/QmSidBKvi8CcbqK5TZdAq1cxFBJAYwUWmg6VwwPtVK2eyT"
],
"telemetryEndpoints": null,
"protocolId": null,
"consensusEngine": null,
"properties": null,
/// A runtime module that interprets a sipmlified pi calculus
use support::{decl_module, decl_storage, decl_event, StorageMap, dispatch::Result, ensure};
use system::ensure_signed;
use rstd::boxed::Box;
use codec::{ Encode, Decode };
use sr_primitives::traits::Hash;
/// All the types of processes in our calculus
######################################
+++ Winner Validators:
#1 == W3F-012 [578e1d3e796c1df204ceb0dd0841b28df59ca81b1e49e0c81e08da11eb088158 (EZ7uBY7Z...)]
[stake_total: 26827_KSM (26,827,164,243,973,954)] [vote_count: 5] [ctrl: Some(1e4c6490abbc74684fa6a32b771a6ace358279948b2655685236679ea8d1af67 (DG3eXF79...))]
#2 == cp287-cloudwalk [30599dba50b5f3ba0b36f856a761eb3c0aee61e830d4beb448ef94b6ad92be39 (DfiSM1qq...)]
[stake_total: 22056_KSM (22,056,129,553,895,962)] [vote_count: 15] [ctrl: Some(30599dba50b5f3ba0b36f856a761eb3c0aee61e830d4beb448ef94b6ad92be39 (DfiSM1qq...))]
#3 == W3F-020 [9ee6f9ef5cb4d24b3519c7efca31a60dc27c215100014e50f8871feb381aebba (GAfhRsNq...)]
fio --randrepeat=1 --ioengine=posixaio --direct=1 --gtod_reduce=1 --name=test --filename=test --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75