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
00ec4132
Commit
00ec4132
authored
May 20, 2015
by
zsfelfoldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storing tx receipts in extraDb
parent
79042223
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
block_processor.go
core/block_processor.go
+16
-0
xeth.go
xeth/xeth.go
+18
-0
No files found.
core/block_processor.go
View file @
00ec4132
...
@@ -23,6 +23,8 @@ const (
...
@@ -23,6 +23,8 @@ const (
BlockChainVersion
=
2
BlockChainVersion
=
2
)
)
var
receiptsPre
=
[]
byte
(
"receipts-"
)
type
BlockProcessor
struct
{
type
BlockProcessor
struct
{
db
common
.
Database
db
common
.
Database
extraDb
common
.
Database
extraDb
common
.
Database
...
@@ -262,9 +264,23 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
...
@@ -262,9 +264,23 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
))
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
))
}
}
receiptsRlp
:=
block
.
Receipts
()
.
RlpEncode
()
sm
.
extraDb
.
Put
(
append
(
receiptsPre
,
block
.
Hash
()
.
Bytes
()
...
),
receiptsRlp
)
return
state
.
Logs
(),
nil
return
state
.
Logs
(),
nil
}
}
func
(
self
*
BlockProcessor
)
GetBlockReceipts
(
bhash
common
.
Hash
)
(
receipts
types
.
Receipts
,
err
error
)
{
var
rdata
[]
byte
rdata
,
err
=
self
.
extraDb
.
Get
(
append
(
receiptsPre
,
bhash
[
:
]
...
))
if
err
==
nil
{
err
=
rlp
.
DecodeBytes
(
rdata
,
&
receipts
)
}
return
}
// Validates the current block. Returns an error if the block was invalid,
// Validates the current block. Returns an error if the block was invalid,
// an uncle or anything that isn't on the current block chain.
// an uncle or anything that isn't on the current block chain.
// Validation validates easy over difficult (dagger takes longer time = difficult)
// Validation validates easy over difficult (dagger takes longer time = difficult)
...
...
xeth/xeth.go
View file @
00ec4132
...
@@ -350,6 +350,24 @@ func (self *XEth) CurrentBlock() *types.Block {
...
@@ -350,6 +350,24 @@ func (self *XEth) CurrentBlock() *types.Block {
return
self
.
backend
.
ChainManager
()
.
CurrentBlock
()
return
self
.
backend
.
ChainManager
()
.
CurrentBlock
()
}
}
func
(
self
*
XEth
)
GetBlockReceipts
(
bhash
common
.
Hash
)
(
receipts
types
.
Receipts
,
err
error
)
{
return
self
.
backend
.
BlockProcessor
()
.
GetBlockReceipts
(
bhash
)
}
func
(
self
*
XEth
)
GetTxReceipt
(
txhash
common
.
Hash
)
(
receipt
*
types
.
Receipt
,
err
error
)
{
_
,
bhash
,
_
,
txi
:=
self
.
EthTransactionByHash
(
common
.
ToHex
(
txhash
[
:
]))
var
receipts
types
.
Receipts
receipts
,
err
=
self
.
backend
.
BlockProcessor
()
.
GetBlockReceipts
(
bhash
)
if
err
==
nil
{
if
txi
<
uint64
(
len
(
receipts
))
{
receipt
=
receipts
[
txi
]
}
else
{
err
=
fmt
.
Errorf
(
"Invalid tx index"
)
}
}
return
}
func
(
self
*
XEth
)
GasLimit
()
*
big
.
Int
{
func
(
self
*
XEth
)
GasLimit
()
*
big
.
Int
{
return
self
.
backend
.
ChainManager
()
.
GasLimit
()
return
self
.
backend
.
ChainManager
()
.
GasLimit
()
}
}
...
...
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