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
c5478833
Commit
c5478833
authored
May 02, 2014
by
Maran
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/rpc
parents
ebdf339a
70c86566
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
63 deletions
+66
-63
keypair.go
ethchain/keypair.go
+10
-0
state_object.go
ethchain/state_object.go
+0
-1
transaction_pool.go
ethchain/transaction_pool.go
+6
-8
vm.go
ethchain/vm.go
+18
-26
ethereum.go
ethereum.go
+1
-1
natupnp.go
natupnp.go
+4
-0
peer.go
peer.go
+27
-27
No files found.
ethchain/keypair.go
View file @
c5478833
...
...
@@ -2,6 +2,7 @@ package ethchain
import
(
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
"math/big"
)
...
...
@@ -14,6 +15,15 @@ type KeyPair struct {
state
*
State
}
func
NewKeyPairFromSec
(
seckey
[]
byte
)
(
*
KeyPair
,
error
)
{
pubkey
,
err
:=
secp256k1
.
GeneratePubKey
(
seckey
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
KeyPair
{
PrivateKey
:
seckey
,
PublicKey
:
pubkey
},
nil
}
func
NewKeyPairFromValue
(
val
*
ethutil
.
Value
)
*
KeyPair
{
keyPair
:=
&
KeyPair
{
PrivateKey
:
val
.
Get
(
0
)
.
Bytes
(),
PublicKey
:
val
.
Get
(
1
)
.
Bytes
()}
...
...
ethchain/state_object.go
View file @
c5478833
...
...
@@ -80,7 +80,6 @@ func (c *StateObject) SetAddr(addr []byte, value interface{}) {
func
(
c
*
StateObject
)
SetMem
(
num
*
big
.
Int
,
val
*
ethutil
.
Value
)
{
addr
:=
ethutil
.
BigToBytes
(
num
,
256
)
c
.
SetAddr
(
addr
,
val
)
//c.state.trie.Update(string(addr), string(val.Encode()))
}
func
(
c
*
StateObject
)
GetMem
(
num
*
big
.
Int
)
*
ethutil
.
Value
{
...
...
ethchain/transaction_pool.go
View file @
c5478833
...
...
@@ -91,14 +91,12 @@ func (pool *TxPool) addTransaction(tx *Transaction) {
// Process transaction validates the Tx and processes funds from the
// sender to the recipient.
func
(
pool
*
TxPool
)
ProcessTransaction
(
tx
*
Transaction
,
block
*
Block
,
toContract
bool
)
(
err
error
)
{
/*
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Println
(
r
)
err
=
fmt
.
Errorf
(
"%v"
,
r
)
}
}()
*/
// Get the sender
sender
:=
block
.
state
.
GetAccount
(
tx
.
Sender
())
...
...
ethchain/vm.go
View file @
c5478833
...
...
@@ -73,10 +73,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
}
}()
// If the amount of gas supplied is less equal to 0
if
closure
.
Gas
.
Cmp
(
big
.
NewInt
(
0
))
<=
0
{
// TODO Do something
}
ethutil
.
Config
.
Log
.
Debugf
(
"[VM] Running closure %x
\n
"
,
closure
.
object
.
Address
())
// Memory for the current closure
mem
:=
&
Memory
{}
...
...
@@ -107,9 +104,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
val
:=
closure
.
Get
(
pc
)
// Get the opcode (it must be an opcode!)
op
:=
OpCode
(
val
.
Uint
())
/*
if ethutil.Config.Debug {
ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String())
}
*/
gas
:=
new
(
big
.
Int
)
useGas
:=
func
(
amount
*
big
.
Int
)
{
...
...
@@ -163,9 +162,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
oLOG
:
stack
.
Print
()
mem
.
Print
()
case
oSTOP
:
// Stop the closure
return
closure
.
Return
(
nil
),
nil
// 0x20 range
case
oADD
:
require
(
2
)
...
...
@@ -520,22 +516,18 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
return
closure
.
Return
(
ret
),
nil
case
oSUICIDE
:
/*
recAddr := stack.Pop().Bytes()
// Purge all memory
deletedMemory := contract.state.Purge()
// Add refunds to the pop'ed address
refund := new(big.Int).Mul(StoreFee, big.NewInt(int64(deletedMemory)))
account := state.GetAccount(recAddr)
account.Amount.Add(account.Amount, refund)
// Update the refunding address
state.UpdateAccount(recAddr, account)
// Delete the contract
state.trie.Update(string(addr), "")
ethutil.Config.Log.Debugf("(%d) => %x\n", deletedMemory, recAddr)
break out
*/
require
(
1
)
receiver
:=
vm
.
state
.
GetAccount
(
stack
.
Pop
()
.
Bytes
())
receiver
.
AddAmount
(
closure
.
object
.
Amount
)
vm
.
stateManager
.
manifest
.
AddObjectChange
(
receiver
)
closure
.
object
.
state
.
Purge
()
fallthrough
case
oSTOP
:
// Stop the closure
return
closure
.
Return
(
nil
),
nil
default
:
ethutil
.
Config
.
Log
.
Debugf
(
"Invalid opcode %x
\n
"
,
op
)
...
...
ethereum.go
View file @
c5478833
...
...
@@ -354,7 +354,7 @@ func (s *Ethereum) WaitForShutdown() {
func
(
s
*
Ethereum
)
upnpUpdateThread
()
{
// Go off immediately to prevent code duplication, thereafter we renew
// lease every 15 minutes.
timer
:=
time
.
NewTimer
(
0
*
time
.
Second
)
timer
:=
time
.
NewTimer
(
5
*
time
.
Minute
)
lport
,
_
:=
strconv
.
ParseInt
(
s
.
Port
,
10
,
16
)
first
:=
true
out
:
...
...
natupnp.go
View file @
c5478833
...
...
@@ -246,6 +246,10 @@ func soapRequest(url, function, message string) (r *http.Response, err error) {
//fmt.Println(fullMessage)
r
,
err
=
http
.
DefaultClient
.
Do
(
req
)
if
err
!=
nil
{
return
}
if
r
.
Body
!=
nil
{
defer
r
.
Body
.
Close
()
}
...
...
peer.go
View file @
c5478833
...
...
@@ -440,14 +440,14 @@ func (p *Peer) HandleInbound() {
// If a parent is found send back a reply
if
parent
!=
nil
{
ethutil
.
Config
.
Log
.
Info
f
(
"[PEER] Found conical block, returning chain from: %x "
,
parent
.
Hash
())
ethutil
.
Config
.
Log
.
Debug
f
(
"[PEER] Found conical block, returning chain from: %x "
,
parent
.
Hash
())
chain
:=
p
.
ethereum
.
BlockChain
()
.
GetChainFromHash
(
parent
.
Hash
(),
amountOfBlocks
)
if
len
(
chain
)
>
0
{
ethutil
.
Config
.
Log
.
Info
f
(
"[PEER] Returning %d blocks: %x "
,
len
(
chain
),
parent
.
Hash
())
ethutil
.
Config
.
Log
.
Debug
f
(
"[PEER] Returning %d blocks: %x "
,
len
(
chain
),
parent
.
Hash
())
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgBlockTy
,
chain
))
}
}
else
{
ethutil
.
Config
.
Log
.
Info
f
(
"[PEER] Could not find a similar block"
)
ethutil
.
Config
.
Log
.
Debug
f
(
"[PEER] Could not find a similar block"
)
// If no blocks are found we send back a reply with msg not in chain
// and the last hash from get chain
lastHash
:=
msg
.
Data
.
Get
(
l
-
1
)
...
...
@@ -455,7 +455,7 @@ func (p *Peer) HandleInbound() {
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgNotInChainTy
,
[]
interface
{}{
lastHash
.
Raw
()}))
}
case
ethwire
.
MsgNotInChainTy
:
ethutil
.
Config
.
Log
.
Info
f
(
"Not in chain %x
\n
"
,
msg
.
Data
)
ethutil
.
Config
.
Log
.
Debug
f
(
"Not in chain %x
\n
"
,
msg
.
Data
)
// TODO
case
ethwire
.
MsgGetTxsTy
:
// Get the current transactions of the pool
...
...
@@ -478,29 +478,6 @@ func (p *Peer) HandleInbound() {
p
.
Stop
()
}
func
packAddr
(
address
,
port
string
)
([]
interface
{},
uint16
)
{
addr
:=
strings
.
Split
(
address
,
"."
)
a
,
_
:=
strconv
.
Atoi
(
addr
[
0
])
b
,
_
:=
strconv
.
Atoi
(
addr
[
1
])
c
,
_
:=
strconv
.
Atoi
(
addr
[
2
])
d
,
_
:=
strconv
.
Atoi
(
addr
[
3
])
host
:=
[]
interface
{}{
int32
(
a
),
int32
(
b
),
int32
(
c
),
int32
(
d
)}
prt
,
_
:=
strconv
.
Atoi
(
port
)
return
host
,
uint16
(
prt
)
}
func
unpackAddr
(
value
*
ethutil
.
Value
,
p
uint64
)
string
{
a
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
0
)
.
Uint
()))
b
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
1
)
.
Uint
()))
c
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
2
)
.
Uint
()))
d
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
3
)
.
Uint
()))
host
:=
strings
.
Join
([]
string
{
a
,
b
,
c
,
d
},
"."
)
port
:=
strconv
.
Itoa
(
int
(
p
))
return
net
.
JoinHostPort
(
host
,
port
)
}
func
(
p
*
Peer
)
Start
()
{
peerHost
,
peerPort
,
_
:=
net
.
SplitHostPort
(
p
.
conn
.
LocalAddr
()
.
String
())
servHost
,
servPort
,
_
:=
net
.
SplitHostPort
(
p
.
conn
.
RemoteAddr
()
.
String
())
...
...
@@ -662,3 +639,26 @@ func (p *Peer) CatchupWithPeer(blockHash []byte) {
func
(
p
*
Peer
)
RlpData
()
[]
interface
{}
{
return
[]
interface
{}{
p
.
host
,
p
.
port
,
p
.
pubkey
}
}
func
packAddr
(
address
,
port
string
)
([]
interface
{},
uint16
)
{
addr
:=
strings
.
Split
(
address
,
"."
)
a
,
_
:=
strconv
.
Atoi
(
addr
[
0
])
b
,
_
:=
strconv
.
Atoi
(
addr
[
1
])
c
,
_
:=
strconv
.
Atoi
(
addr
[
2
])
d
,
_
:=
strconv
.
Atoi
(
addr
[
3
])
host
:=
[]
interface
{}{
int32
(
a
),
int32
(
b
),
int32
(
c
),
int32
(
d
)}
prt
,
_
:=
strconv
.
Atoi
(
port
)
return
host
,
uint16
(
prt
)
}
func
unpackAddr
(
value
*
ethutil
.
Value
,
p
uint64
)
string
{
a
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
0
)
.
Uint
()))
b
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
1
)
.
Uint
()))
c
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
2
)
.
Uint
()))
d
:=
strconv
.
Itoa
(
int
(
value
.
Get
(
3
)
.
Uint
()))
host
:=
strings
.
Join
([]
string
{
a
,
b
,
c
,
d
},
"."
)
port
:=
strconv
.
Itoa
(
int
(
p
))
return
net
.
JoinHostPort
(
host
,
port
)
}
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