Skip to content

Instantly share code, notes, and snippets.

View nodech's full-sized avatar

Nodar Chkuaselidze nodech

  • Tbilisi, Georgia
View GitHub Profile
@nodech
nodech / Mine-Max-Block.js
Created May 16, 2018 22:09
Mine maximum block
it('should mine a big block', async () => {
const OPRETURN = Script.fromNulldata(Buffer.alloc(70, 1));
const start = chain.height - 2000;
const end = chain.height - 200;
const job = await cpu.createJob();
const maxSigops = consensus.maxBlockSigops(consensus.MAX_FORK_BLOCK_SIZE);
const perTxSigops = Math.floor((maxSigops - 1000) / 1801) - 2;
const perTxSize = Math.floor(consensus.MAX_FORK_BLOCK_SIZE / 1801);
// fill max tx
'use strict';
const fs = require('fs');
const bcoin = require('bcoin');
const secp256k1 = bcoin.secp256k1;
const KeyRing = bcoin.keyring;
const PublicKey = bcoin.hd.PublicKey;
const HID = require('node-hid');
const Leveldown = require('leveldown');
const async = require('async');
const KEYS = 10000;
const options = {
createIfMissing : true,
errorIfExists : false,
compression : true,
cacheSize : 8 << 20,
@nodech
nodech / simulate.js
Created September 4, 2017 22:53
Monty Hall Problem (Paradox)
const percent = (a, b) => {
return (a / b * 100).toFixed(2);
}
const getRandomIndex = (n) => {
return Math.floor(Math.random() * n);
};
const getRandomNumbers = (n) => {
const arr = new Array(n);
@nodech
nodech / index.js
Last active February 13, 2022 18:48
BCOIN - Example: Get Entry, Block, Tx from chain
'use strict';
const bcoin = require('bcoin');
const Chain = bcoin.chain;
const Logger = bcoin.logger;
const util = bcoin.util;
let logger = new Logger({
level: 'debug',
});
@nodech
nodech / config.toml
Created August 3, 2017 15:59
Ethermint Config flags to TOML
[Eth]
NetworkId = 1 #
SyncMode = "fast" #
LightPeers = 20 #
DatabaseCache = 128 # --cache
GasPrice = 18000000000 # --gasprice
EthashCacheDir = "ethash" #
EthashCachesInMem = 2 #
EthashCachesOnDisk = 3 #
EthashDatasetDir = "/Users/nd/.ethash" #

Keybase proof

I hereby claim:

  • I am nodar-chkuaselidze on github.
  • I am nodech (https://keybase.io/nodech) on keybase.
  • I have a public key ASDzV1EkeecSAKDssAKgkQBg6-mSKKFyV5xwWxMpqnKtcAo

To claim this, I am signing this object:

@nodech
nodech / test.js
Created May 13, 2016 21:07
Test benchmarks
var o = {};
for (var i = 0; i < 100; i++) {
o['key' + i] = 'value ' + i;
}
exports.compare = {
//#3
"for(var .. in ..)" : function () {
for(var key in o) {
var asaki = 0;
if (asaki < 5) {
console.log("პატარა ხარ ძალიან!");
} else if (asaki < 12) {
console.log("მხოლოდ მშობლების ნებართვით!");
} else if (asaki < 20) {
console.log("კარგები ხართ!");
} else {
console.log("უფროსებისთვის უკეთესი ალტერნატივა გვაქვს.");