Skip to content

Instantly share code, notes, and snippets.

View GeertJohan's full-sized avatar

Geert-Johan Riemer GeertJohan

View GitHub Profile
@GeertJohan
GeertJohan / coinbase.go
Last active August 29, 2015 14:03
This program calculates how many mined coins were sent to which address.
package main
import (
"fmt"
"github.com/conformal/btcrpcclient"
"log"
"sort"
)
// blockCount defines the number of blocks back into history we wish to inspect.
@GeertJohan
GeertJohan / consistent-hashing-tests
Last active August 29, 2015 14:10
consistent-hashing-tests
"github.com/golang/groupcache/consistenthash"
100000 keys over 3 buckets
cacheA: 47356
cacheC: 11779
100000 keys over 9 buckets
cacheH: 10091
cacheI: 30516
cacheG: 7133
type block struct {
height int64
time time.Time
diff *big.Int
}
fatal error: fault
[signal 0xb code=0x80 addr=0x0 pc=0x5852d8]
goroutine 1 [running, locked to thread]:
runtime.gothrow(0x7ac5c0, 0x5)
/home/geertjohan/Applications/go/src/runtime/panic.go:503 +0x8e fp=0xc208087a68 sp=0xc208087a50
runtime.sigpanic()
/home/geertjohan/Applications/go/src/runtime/sigpanic_unix.go:29 +0x265 fp=0xc208087ab8 sp=0xc208087a68
github.com/jteeuwen/go-vlc.goEventCB(0x7f219b3e5e10, 0xc2082342e0)
/home/geertjohan/Workspaces/Go/gopath/src/github.com/jteeuwen/go-vlc/callback.go:32 +0xd8 fp=0xc208087b20 sp=0xc208087ab8
// Digi algorithm should never be used until at least 2 blocks are mined.
// Contains code by RealSolid & WDC
// Cleaned up for use in Guldencoin by GeertJohan (dead code removal since Guldencoin retargets every block)
unsigned int static GetNextWorkRequired_DIGI(const CBlockIndex* pindexLast, const CBlockHeader *pblock){
// retarget timespan is set to a single block spacing because there is a retarget every block
int64 retargetTimespan = nTargetSpacing;
// get previous block
const CBlockIndex* pindexPrev = pindexLast->pprev;
assert(pindexPrev);
// Digi algorithm should never be used until at least 2 blocks are mined.
// Contains code by RealSolid & WDC
// Cleaned up for use in Guldencoin by GeertJohan (dead code removal since Guldencoin retargets every block)
unsigned int static GetNextWorkRequired_DIGI(const CBlockIndex* pindexLast, const CBlockHeader *pblock){
// retarget timespan is set to a single block spacing because there is a retarget every block
int64 retargetTimespan = nTargetSpacing;
// get previous block
const CBlockIndex* pindexPrev = pindexLast->pprev;
assert(pindexPrev);

Clean up Digishield for use in Guldencoin.

Removing unused local variable nHeight.

Both nTargetSpacing and nTargetTimespanNEW are defined as 2.5*60, which means that retargetInterval will always equal 1. This means that (pindexLast->nHeight+1) % retargetInterval will always resolve to 0 and therefore the block following if ((pindexLast->nHeight+1) % retargetInterval != 0) will never be ran. Removing the complete block as it is dead code.

Removing the genesis exception, we're never mining a genesis block with DIGI.

Removing the now unused local variables nProofOfWorkLimit and retargetSpacing.

package main
import (
"fmt"
"github.com/segmentio/go-loggly"
"gopkg.in/inconshreveable/log15.v2"
)
type LogglyHook struct {
package main
import (
"fmt"
"github.com/segmentio/go-loggly"
"gopkg.in/inconshreveable/log15.v2"
)
type LogglyHook struct {
FROM ubuntu
RUN apt-get update && apt-get install -y ktorrent
CMD /usr/bin/ktorrent