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
86ba7432
Commit
86ba7432
authored
Apr 01, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
txMeta storage as struct
parent
b860b676
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
30 deletions
+25
-30
block_processor.go
core/block_processor.go
+11
-17
xeth.go
xeth/xeth.go
+14
-13
No files found.
core/block_processor.go
View file @
86ba7432
...
...
@@ -235,7 +235,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// This puts transactions in a extra db for rpc
for
i
,
tx
:=
range
block
.
Transactions
()
{
putTx
(
sm
.
extraDb
,
tx
,
block
,
i
)
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
)
)
}
if
uncle
{
...
...
@@ -359,7 +359,7 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
return
state
.
Logs
(),
nil
}
func
putTx
(
db
common
.
Database
,
tx
*
types
.
Transaction
,
block
*
types
.
Block
,
i
int
)
{
func
putTx
(
db
common
.
Database
,
tx
*
types
.
Transaction
,
block
*
types
.
Block
,
i
uint64
)
{
rlpEnc
,
err
:=
rlp
.
EncodeToBytes
(
tx
)
if
err
!=
nil
{
statelogger
.
Infoln
(
"Failed encoding tx"
,
err
)
...
...
@@ -367,24 +367,18 @@ func putTx(db common.Database, tx *types.Transaction, block *types.Block, i int)
}
db
.
Put
(
tx
.
Hash
()
.
Bytes
(),
rlpEnc
)
rlpEnc
,
err
=
rlp
.
EncodeToBytes
(
block
.
Hash
()
.
Bytes
())
if
err
!=
nil
{
statelogger
.
Infoln
(
"Failed encoding meta"
,
err
)
return
var
txExtra
struct
{
BlockHash
common
.
Hash
BlockIndex
uint64
Index
uint64
}
db
.
Put
(
append
(
tx
.
Hash
()
.
Bytes
(),
0x0001
),
rlpEnc
)
rlpEnc
,
err
=
rlp
.
EncodeToBytes
(
block
.
Number
()
.
Bytes
())
if
err
!=
nil
{
statelogger
.
Infoln
(
"Failed encoding meta"
,
err
)
return
}
db
.
Put
(
append
(
tx
.
Hash
()
.
Bytes
(),
0x0002
),
rlpEnc
)
rlpEnc
,
err
=
rlp
.
EncodeToBytes
(
i
)
txExtra
.
BlockHash
=
block
.
Hash
()
txExtra
.
BlockIndex
=
block
.
NumberU64
()
txExtra
.
Index
=
i
rlpMeta
,
err
:=
rlp
.
EncodeToBytes
(
txExtra
)
if
err
!=
nil
{
statelogger
.
Infoln
(
"Failed encoding meta"
,
err
)
return
}
db
.
Put
(
append
(
tx
.
Hash
()
.
Bytes
(),
0x000
3
),
rlpEnc
)
db
.
Put
(
append
(
tx
.
Hash
()
.
Bytes
(),
0x000
1
),
rlpMeta
)
}
xeth/xeth.go
View file @
86ba7432
...
...
@@ -19,6 +19,7 @@ import (
"github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/rlp"
)
var
(
...
...
@@ -191,20 +192,20 @@ func (self *XEth) EthTransactionByHash(hash string) (tx *types.Transaction, blha
tx
=
types
.
NewTransactionFromBytes
(
data
)
}
// blockhash
data
,
_
=
self
.
backend
.
ExtraDb
()
.
Get
(
append
(
common
.
FromHex
(
hash
),
0x0001
))
if
len
(
data
)
!=
0
{
blhash
=
common
.
BytesToHash
(
data
)
}
// blocknum
data
,
_
=
self
.
backend
.
ExtraDb
()
.
Get
(
append
(
common
.
FromHex
(
hash
),
0x0002
))
if
len
(
data
)
!=
0
{
blnum
=
common
.
Bytes2Big
(
data
)
// meta
var
txExtra
struct
{
BlockHash
common
.
Hash
BlockIndex
int64
Index
uint64
}
// txindex
data
,
_
=
self
.
backend
.
ExtraDb
()
.
Get
(
append
(
common
.
FromHex
(
hash
),
0x0003
))
if
len
(
data
)
!=
0
{
txi
=
common
.
BytesToNumber
(
data
)
v
,
_
:=
self
.
backend
.
ExtraDb
()
.
Get
(
append
(
common
.
FromHex
(
hash
),
0x0001
))
r
:=
bytes
.
NewReader
(
v
)
err
:=
rlp
.
Decode
(
r
,
&
txExtra
)
if
err
==
nil
{
blhash
=
txExtra
.
BlockHash
blnum
=
big
.
NewInt
(
txExtra
.
BlockIndex
)
txi
=
txExtra
.
Index
}
return
...
...
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