Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
41bd3814
Commit
41bd3814
authored
Jul 26, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up and util methods
parent
92ffc1cc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
26 deletions
+67
-26
block.go
ethchain/block.go
+4
-9
ethereum.go
ethereum.go
+7
-6
bytes.go
ethutil/bytes.go
+1
-0
config.go
ethutil/config.go
+3
-3
path.go
ethutil/path.go
+40
-0
vm.go
ethvm/vm.go
+3
-2
peer.go
peer.go
+9
-6
No files found.
ethchain/block.go
View file @
41bd3814
...
...
@@ -3,13 +3,14 @@ package ethchain
import
(
"bytes"
"fmt"
"math/big"
_
"strconv"
"time"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethtrie"
"github.com/ethereum/eth-go/ethutil"
"math/big"
_
"strconv"
"time"
)
type
BlockInfo
struct
{
...
...
@@ -63,12 +64,6 @@ type Block struct {
TxSha
[]
byte
}
// New block takes a raw encoded string
// XXX DEPRICATED
func
NewBlockFromData
(
raw
[]
byte
)
*
Block
{
return
NewBlockFromBytes
(
raw
)
}
func
NewBlockFromBytes
(
raw
[]
byte
)
*
Block
{
block
:=
&
Block
{}
block
.
RlpDecode
(
raw
)
...
...
ethereum.go
View file @
41bd3814
...
...
@@ -3,12 +3,6 @@ package eth
import
(
"container/list"
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethrpc"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"io/ioutil"
"math/rand"
"net"
...
...
@@ -18,6 +12,13 @@ import (
"sync"
"sync/atomic"
"time"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethrpc"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
)
const
seedTextFileUri
string
=
"http://www.ethereum.org/servers.poc3.txt"
...
...
ethutil/bytes.go
View file @
41bd3814
...
...
@@ -98,6 +98,7 @@ func Bytes2Hex(d []byte) string {
func
Hex2Bytes
(
str
string
)
[]
byte
{
h
,
_
:=
hex
.
DecodeString
(
str
)
return
h
}
...
...
ethutil/config.go
View file @
41bd3814
...
...
@@ -3,8 +3,9 @@ package ethutil
import
(
"flag"
"fmt"
"github.com/rakyll/globalconf"
"os"
"github.com/rakyll/globalconf"
)
// Config struct
...
...
@@ -28,8 +29,7 @@ var Config *ConfigManager
func
ReadConfig
(
ConfigFile
string
,
Datadir
string
,
EnvPrefix
string
)
*
ConfigManager
{
if
Config
==
nil
{
// create ConfigFile if does not exist, otherwise globalconf panic when trying to persist flags
_
,
err
:=
os
.
Stat
(
ConfigFile
)
if
err
!=
nil
&&
os
.
IsNotExist
(
err
)
{
if
!
FileExist
(
ConfigFile
)
{
fmt
.
Printf
(
"config file '%s' doesn't exist, creating it
\n
"
,
ConfigFile
)
os
.
Create
(
ConfigFile
)
}
...
...
ethutil/path.go
View file @
41bd3814
package
ethutil
import
(
"io/ioutil"
"os"
"os/user"
"strings"
)
...
...
@@ -18,3 +20,41 @@ func ExpandHomePath(p string) (path string) {
return
}
func
FileExist
(
filePath
string
)
bool
{
_
,
err
:=
os
.
Stat
(
filePath
)
if
err
!=
nil
&&
os
.
IsNotExist
(
err
)
{
return
false
}
return
true
}
func
ReadAllFile
(
filePath
string
)
(
string
,
error
)
{
file
,
err
:=
os
.
Open
(
filePath
)
if
err
!=
nil
{
return
""
,
err
}
data
,
err
:=
ioutil
.
ReadAll
(
file
)
if
err
!=
nil
{
return
""
,
err
}
return
string
(
data
),
nil
}
func
WriteFile
(
filePath
string
,
content
[]
byte
)
error
{
fh
,
err
:=
os
.
OpenFile
(
filePath
,
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
if
err
!=
nil
{
return
err
}
defer
fh
.
Close
()
_
,
err
=
fh
.
Write
(
content
)
if
err
!=
nil
{
return
err
}
return
nil
}
ethvm/vm.go
View file @
41bd3814
...
...
@@ -2,11 +2,12 @@ package ethvm
import
(
"fmt"
"math"
"math/big"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"math"
"math/big"
)
type
Debugger
interface
{
...
...
peer.go
View file @
41bd3814
...
...
@@ -4,15 +4,16 @@ import (
"bytes"
"container/list"
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"net"
"strconv"
"strings"
"sync/atomic"
"time"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
)
var
peerlogger
=
ethlog
.
NewLogger
(
"PEER"
)
...
...
@@ -197,10 +198,12 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
}
func
(
self
*
Peer
)
Connect
(
addr
string
)
(
conn
net
.
Conn
,
err
error
)
{
for
attempts
:=
0
;
attempts
<
5
;
attempts
++
{
const
maxTries
=
3
for
attempts
:=
0
;
attempts
<
maxTries
;
attempts
++
{
conn
,
err
=
net
.
DialTimeout
(
"tcp"
,
addr
,
10
*
time
.
Second
)
if
err
!=
nil
{
peerlogger
.
Debugf
(
"Peer connection failed. Retrying (%d/5)
\n
"
,
attempts
+
1
)
//peerlogger.Debugf("Peer connection failed. Retrying (%d/%d) (%s)\n", attempts+1, maxTries, addr)
time
.
Sleep
(
time
.
Duration
(
attempts
*
20
)
*
time
.
Second
)
continue
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment