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
43cad690
Commit
43cad690
authored
Mar 27, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked transaction constructors
parent
308c5932
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
15 deletions
+60
-15
keypair.go
ethchain/keypair.go
+3
-0
transaction.go
ethchain/transaction.go
+53
-13
vm.go
ethchain/vm.go
+2
-1
peer.go
peer.go
+2
-1
No files found.
ethchain/keypair.go
View file @
43cad690
...
...
@@ -34,6 +34,7 @@ func (k *KeyPair) Account() *Account {
// Create transaction, creates a new and signed transaction, ready for processing
func
(
k
*
KeyPair
)
CreateTx
(
receiver
[]
byte
,
value
*
big
.
Int
,
data
[]
string
)
*
Transaction
{
/* TODO
tx := NewTransaction(receiver, value, data)
tx.Nonce = k.account.Nonce
...
...
@@ -41,6 +42,8 @@ func (k *KeyPair) CreateTx(receiver []byte, value *big.Int, data []string) *Tran
tx.Sign(k.PrivateKey)
return tx
*/
return
nil
}
func
(
k
*
KeyPair
)
RlpEncode
()
[]
byte
{
...
...
ethchain/transaction.go
View file @
43cad690
...
...
@@ -18,16 +18,21 @@ type Transaction struct {
Data
[]
string
v
byte
r
,
s
[]
byte
// Indicates whether this tx is a contract creation transaction
contractCreation
bool
}
/*
func NewTransaction(to []byte, value *big.Int, data []string) *Transaction {
tx := Transaction{Recipient: to, Value: value, Nonce: 0, Data: data}
return &tx
}
*/
func
NewContractCreationTx
(
value
,
gasprice
*
big
.
Int
,
data
[]
string
)
*
Transaction
{
return
&
Transaction
{
Value
:
value
,
Gasprice
:
gasprice
,
Data
:
data
}
return
&
Transaction
{
Value
:
value
,
Gasprice
:
gasprice
,
Data
:
data
,
contractCreation
:
true
}
}
func
NewContractMessageTx
(
to
[]
byte
,
value
,
gasprice
,
gas
*
big
.
Int
,
data
[]
string
)
*
Transaction
{
...
...
@@ -38,10 +43,12 @@ func NewTx(to []byte, value *big.Int, data []string) *Transaction {
return
&
Transaction
{
Recipient
:
to
,
Value
:
value
,
Gasprice
:
big
.
NewInt
(
0
),
Gas
:
big
.
NewInt
(
0
),
Nonce
:
0
,
Data
:
data
}
}
/*
// XXX Deprecated
func NewTransactionFromData(data []byte) *Transaction {
return NewTransactionFromBytes(data)
}
*/
func
NewTransactionFromBytes
(
data
[]
byte
)
*
Transaction
{
tx
:=
&
Transaction
{}
...
...
@@ -148,19 +155,52 @@ func (tx *Transaction) RlpDecode(data []byte) {
tx
.
RlpValueDecode
(
ethutil
.
NewValueFromBytes
(
data
))
}
// [ NONCE, VALUE, GASPRICE, TO, GAS, DATA, V, R, S ]
func
(
tx
*
Transaction
)
RlpValueDecode
(
decoder
*
ethutil
.
Value
)
{
tx
.
Nonce
=
decoder
.
Get
(
0
)
.
Uint
()
tx
.
Recipient
=
decoder
.
Get
(
1
)
.
Bytes
()
tx
.
Value
=
decoder
.
Get
(
2
)
.
BigInt
()
d
:=
decoder
.
Get
(
3
)
tx
.
Data
=
make
([]
string
,
d
.
Len
())
for
i
:=
0
;
i
<
d
.
Len
();
i
++
{
tx
.
Data
[
i
]
=
d
.
Get
(
i
)
.
Str
()
tx
.
Value
=
decoder
.
Get
(
1
)
.
BigInt
()
tx
.
Gasprice
=
decoder
.
Get
(
2
)
.
BigInt
()
// If the 4th item is a list(slice) this tx
// is a contract creation tx
if
decoder
.
Get
(
3
)
.
IsSlice
()
{
d
:=
decoder
.
Get
(
3
)
tx
.
Data
=
make
([]
string
,
d
.
Len
())
for
i
:=
0
;
i
<
d
.
Len
();
i
++
{
tx
.
Data
[
i
]
=
d
.
Get
(
i
)
.
Str
()
}
tx
.
v
=
byte
(
decoder
.
Get
(
4
)
.
Uint
())
tx
.
r
=
decoder
.
Get
(
5
)
.
Bytes
()
tx
.
s
=
decoder
.
Get
(
6
)
.
Bytes
()
tx
.
contractCreation
=
true
}
else
{
tx
.
Recipient
=
decoder
.
Get
(
3
)
.
Bytes
()
tx
.
Gas
=
decoder
.
Get
(
4
)
.
BigInt
()
d
:=
decoder
.
Get
(
5
)
tx
.
Data
=
make
([]
string
,
d
.
Len
())
for
i
:=
0
;
i
<
d
.
Len
();
i
++
{
tx
.
Data
[
i
]
=
d
.
Get
(
i
)
.
Str
()
}
tx
.
v
=
byte
(
decoder
.
Get
(
6
)
.
Uint
())
tx
.
r
=
decoder
.
Get
(
7
)
.
Bytes
()
tx
.
s
=
decoder
.
Get
(
8
)
.
Bytes
()
}
// TODO something going wrong here
tx
.
v
=
byte
(
decoder
.
Get
(
4
)
.
Uint
())
tx
.
r
=
decoder
.
Get
(
5
)
.
Bytes
()
tx
.
s
=
decoder
.
Get
(
6
)
.
Bytes
()
/*
tx.Nonce = decoder.Get(0).Uint()
tx.Recipient = decoder.Get(1).Bytes()
tx.Value = decoder.Get(2).BigInt()
d := decoder.Get(3)
tx.Data = make([]string, d.Len())
for i := 0; i < d.Len(); i++ {
tx.Data[i] = d.Get(i).Str()
}
tx.v = byte(decoder.Get(4).Uint())
tx.r = decoder.Get(5).Bytes()
tx.s = decoder.Get(6).Bytes()
*/
}
ethchain/vm.go
View file @
43cad690
...
...
@@ -5,7 +5,6 @@ import (
_
"fmt"
"github.com/ethereum/eth-go/ethutil"
_
"github.com/obscuren/secp256k1-go"
"log"
_
"math"
"math/big"
)
...
...
@@ -359,6 +358,7 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
}
}
/*
func makeInlineTx(addr []byte, value, from, length *big.Int, contract *Contract, state *State) {
ethutil.Config.Log.Debugf(" => creating inline tx %x %v %v %v", addr, value, from, length)
j := int64(0)
...
...
@@ -395,3 +395,4 @@ func contractMemory(state *State, contractAddr []byte, memAddr *big.Int) *big.In
return decoder.BigInt()
}
*/
peer.go
View file @
43cad690
...
...
@@ -334,7 +334,8 @@ func (p *Peer) HandleInbound() {
// in the TxPool where it will undergo validation and
// processing when a new block is found
for
i
:=
0
;
i
<
msg
.
Data
.
Len
();
i
++
{
p
.
ethereum
.
TxPool
()
.
QueueTransaction
(
ethchain
.
NewTransactionFromData
(
msg
.
Data
.
Get
(
i
)
.
Encode
()))
//p.ethereum.TxPool().QueueTransaction(ethchain.NewTransactionFromData(msg.Data.Get(i).Encode()))
p
.
ethereum
.
TxPool
()
.
QueueTransaction
(
ethchain
.
NewTransactionFromValue
(
msg
.
Data
.
Get
(
i
)))
}
case
ethwire
.
MsgGetPeersTy
:
// Flag this peer as a 'requested of new peers' this to
...
...
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