Skip to content

Instantly share code, notes, and snippets.

@tymat
Last active August 29, 2015 14:02

Revisions

  1. tymat revised this gist Jun 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ func heartbeat() var {
    this.store[1002] = this.time()
    return true
    } else {
    if this.store[1002] > 2592000 {
    if this.time() this.store[1002] - 2592000 {
    return false
    } else {
    return true
  2. tymat revised this gist Jun 6, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -58,3 +58,5 @@ func run() {
    }
    }
    }

    run()
  3. tymat created this gist Jun 6, 2014.
    60 changes: 60 additions & 0 deletions gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    #define CLAIMER 0xd766c288f24b91ae9781fe2b155d3260b8674c62
    this.store[1000] = this.origin()

    func heartbeat() var {
    if this.store[1000] == this.origin() {
    this.store[1002] = this.time()
    return true
    } else {
    if this.store[1002] > 2592000 {
    return false
    } else {
    return true
    }
    }
    }

    func claim() var {
    if this.origin() == CLAIMER {
    h := heartbeat()
    if h == false {
    transact(CLAIMER, this.balance(), nil)
    return true
    } else {
    return false
    }
    }
    }

    func withdraw(var amount, var address) var {
    if this.store[1000] == this.origin() {
    h := heartbeat()
    if h == true {
    return transact(address, amount, nil)
    } else {
    return false
    }
    }
    }

    func run() {
    if this.store[1000] == this.origin() {
    if this.data[0] == "heartbeat" {
    h := heartbeat()
    return h
    } else {
    address := this.data[1]
    amount := this.data[2]
    return withdraw(address, amount)
    }
    }

    if this.origin() == CLAIMER {
    if this.data[0] == "claim" {
    c := claim()
    return c
    } else {
    return false
    }
    }
    }