gofmt no coding standards

This commit is contained in:
obscuren 2014-01-11 15:27:08 +01:00
parent 8bbf879cb3
commit 9571a51286
14 changed files with 922 additions and 887 deletions

View File

@ -21,3 +21,8 @@ Command line options
-c launch the developer console
-m start mining fake blocks and broadcast fake messages to the net
Contribution
============
See CONTRIB.md

View File

@ -1,12 +1,12 @@
package main
import (
"github.com/ethereum/ethutil-go"
"github.com/obscuren/sha3"
"hash"
"math/big"
"math/rand"
"time"
"github.com/obscuren/sha3"
"hash"
"github.com/ethereum/ethutil-go"
)
type Dagger struct {
@ -15,6 +15,7 @@ type Dagger struct {
}
var Found bool
func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
@ -29,7 +30,9 @@ func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
}
// Break out if found
if Found { break }
if Found {
break
}
}
resChan <- 0

View File

@ -1,8 +1,8 @@
package main
import (
"testing"
"math/big"
"testing"
)
func BenchmarkDaggerSearch(b *testing.B) {

View File

@ -1,14 +1,14 @@
package main
import (
"fmt"
"bufio"
"strings"
"os"
"errors"
"encoding/hex"
"errors"
"fmt"
"github.com/ethereum/ethdb-go"
"github.com/ethereum/ethutil-go"
"os"
"strings"
)
type Console struct {
@ -60,7 +60,9 @@ func (i *Console) ParseInput(input string) bool {
fmt.Fprintln(os.Stderr, "reading input:", err)
}
if len(tokens) == 0 { return true }
if len(tokens) == 0 {
return true
}
err := i.ValidateInput(tokens[0], count-1)
if err != nil {

View File

@ -1,19 +1,20 @@
package main
import (
"flag"
"fmt"
"github.com/ethereum/ethutil-go"
"log"
"os"
"os/signal"
"flag"
"runtime"
"log"
"github.com/ethereum/ethutil-go"
)
const Debug = true
var StartConsole bool
var StartMining bool
func Init() {
flag.BoolVar(&StartConsole, "c", false, "debug and testing console")
flag.BoolVar(&StartMining, "m", false, "start dagger mining")
@ -78,7 +79,6 @@ func main() {
return
}
// Wait for shutdown
server.WaitForShutdown()
}

View File

@ -1,9 +1,9 @@
package main
import (
"net"
"log"
"github.com/ethereum/ethwire-go"
"log"
"net"
)
type Peer struct {

18
rlp.go
View File

@ -1,16 +1,17 @@
package main
import (
"fmt"
"bytes"
"fmt"
"github.com/ethereum/ethutil-go"
"math"
"math/big"
"github.com/ethereum/ethutil-go"
)
type RlpEncoder struct {
rlpData []byte
}
func NewRlpEncoder() *RlpEncoder {
encoder := &RlpEncoder{}
@ -95,6 +96,7 @@ func (attr *RlpDataAttribute) Get(idx int) *RlpDataAttribute {
type RlpDecoder struct {
rlpData interface{}
}
func NewRlpDecoder(rlpData []byte) *RlpDecoder {
decoder := &RlpDecoder{}
// Decode the data
@ -110,7 +112,9 @@ func (dec *RlpDecoder) Get(idx int) *RlpDataAttribute {
/// Raw methods
func BinaryLength(n uint64) uint64 {
if n == 0 { return 0 }
if n == 0 {
return 0
}
return 1 + BinaryLength(n/256)
}
@ -120,7 +124,9 @@ func ToBinarySlice(n uint64, length uint64) []uint64 {
length = BinaryLength(n)
}
if n == 0 { return make([]uint64, 1) }
if n == 0 {
return make([]uint64, 1)
}
slice := ToBinarySlice(n/256, 0)
slice = append(slice, n%256)
@ -138,7 +144,9 @@ func ToBin(n uint64, length uint64) string {
}
func FromBin(data []byte) uint64 {
if len(data) == 0 { return 0 }
if len(data) == 0 {
return 0
}
return FromBin(data[:len(data)-1])*256 + uint64(data[len(data)-1])
}

View File

@ -1,8 +1,8 @@
package main
import (
"testing"
"fmt"
"testing"
)
func TestEncode(t *testing.T) {

View File

@ -2,11 +2,11 @@ package main
import (
"container/list"
"net"
"log"
_"time"
"github.com/ethereum/ethdb-go"
"github.com/ethereum/ethutil-go"
"log"
"net"
_ "time"
)
type Server struct {
@ -57,7 +57,6 @@ func (s *Server) ConnectToPeer(addr string) error {
s.peers.PushBack(peer)
peer.Start()
log.Println("Connected to peer ::", conn.RemoteAddr())
return nil

View File

@ -1,9 +1,9 @@
package main
import (
"encoding/json"
"fmt"
"testing"
"encoding/json"
)
type TestSource struct {

View File

@ -1,9 +1,9 @@
package main
import (
"encoding/hex"
_ "fmt"
"testing"
"encoding/hex"
)
var testsource = `{"Inputs":{

View File

@ -1,4 +1,5 @@
package main
/*
import (

35
vm.go
View File

@ -1,10 +1,10 @@
package main
import (
"math/big"
"fmt"
"strconv"
"github.com/ethereum/ethutil-go"
"math/big"
"strconv"
)
// Op codes
@ -61,18 +61,21 @@ const (
)
type OpType int
const (
tNorm = iota
tData
tExtro
tCrypto
)
type TxCallback func(opType OpType) bool
// Simple push/pop stack mechanism
type Stack struct {
data []string
}
func NewStack() *Stack {
return &Stack{}
}
@ -136,7 +139,9 @@ out:
nb := ethutil.NumberToBytes(uint64(pc), 32)
op, _, _ := ethutil.Instr(contract.State().Get(string(nb)))
if !cb(0) { break }
if !cb(0) {
break
}
if Debug {
//fmt.Printf("%-3d %-4d\n", pc, op)
@ -173,11 +178,17 @@ out:
case oSDIV:
x, y := vm.stack.Popn()
// n > 2**255
if x.Cmp(Pow256) > 0 { x.Sub(Pow256, x) }
if y.Cmp(Pow256) > 0 { y.Sub(Pow256, y) }
if x.Cmp(Pow256) > 0 {
x.Sub(Pow256, x)
}
if y.Cmp(Pow256) > 0 {
y.Sub(Pow256, y)
}
z := new(big.Int)
z.Div(x, y)
if z.Cmp(Pow256) > 0 { z.Sub(Pow256, z) }
if z.Cmp(Pow256) > 0 {
z.Sub(Pow256, z)
}
// Push result on to the stack
vm.stack.Push(z.String())
case oMOD:
@ -187,11 +198,17 @@ out:
case oSMOD:
x, y := vm.stack.Popn()
// n > 2**255
if x.Cmp(Pow256) > 0 { x.Sub(Pow256, x) }
if y.Cmp(Pow256) > 0 { y.Sub(Pow256, y) }
if x.Cmp(Pow256) > 0 {
x.Sub(Pow256, x)
}
if y.Cmp(Pow256) > 0 {
y.Sub(Pow256, y)
}
z := new(big.Int)
z.Mod(x, y)
if z.Cmp(Pow256) > 0 { z.Sub(Pow256, z) }
if z.Cmp(Pow256) > 0 {
z.Sub(Pow256, z)
}
// Push result on to the stack
vm.stack.Push(z.String())
case oEXP: