This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 165
tx/address indexing as optional feature, with separate db #475
Merged
Merged
Changes from 4 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
a778e22
feat: create WIP prototype for tx/address indexing
whilei 71c0b77
dep ensure
whilei d87a807
init batching sketch
whilei ffaed6a
use delegated batching for atxi cmd
whilei 3a39d4c
dep ensure: remove progress bar deps
whilei 031c198
Rename AddTxIndexesBatch->WriteBlockAddrTxIndexesBatch
whilei 63f5c83
write atxis for bc insertreceipts and reorg
whilei 4b45f42
remove atxis given bc rollback or reorg
whilei e09bd1a
improvements based on @tzdybal feedback
whilei 0fd5868
rename toOrFromOrBoth -> direction
whilei ec6f4e6
compare uint64s blockstart/stopNs instead of converting to bigints
whilei 674da81
simplify t/f direction check for iterator
whilei cd429f7
rename more toOrFrom -> direction
whilei 0c746d3
refactor putBlockAddrTxsToBatch and atxi-build cmd
whilei 0c38d84
Add comments and remove unused fn
whilei 67769f6
a few minor tweaks and improvements, comments, etc
whilei 4fc155f
move atxi placeholder to db k/v, polish cmd ui
whilei 74d7fe0
write test for atxi, refactor, and fix bu
whilei cdb4055
test for fast/full sync implements atxi if enabled
whilei 2ef0157
problem: atxi not removing indexes
whilei 258d418
problem: weirdly named signature var for tx Diff fn
whilei 2644af4
problem: duplicate txs hashes return when chain reorg
whilei 4bb36a1
problem: no tests for atxi rm or reorg
whilei 429d2ab
allow empty tx.to to allow querying just contracts
whilei bf00bf0
minor refactorings for code cleanliness, see pr code comments
whilei a7dbbb5
solution: implement addition param for standard/contract filter
whilei 8f36212
problem: nix pointer on contract tx type putting atxi
whilei 0ba44ce
problem: don't skip atxi for to==nil txs
whilei cb4ed85
problem: unhandled index db allowance
whilei 55a7eff
problem: no formatter for web3ext input formatter
whilei 5807140
Merge branch 'master' into feat/addr-tx-index-proto
whilei f2eb1ba
problem: api should use human-friendly t|f|tf/ft interface
whilei e4f15d2
Merge master and resolve conflicts
whilei 513ad88
solution: remove redundant horizontal rule from usage output
whilei 02efe7f
gofmt: project-wide
whilei a29921a
problem: merge missed atxi command/flag additions
whilei 54773f6
solution: add comment to explain cache ratio sharing
whilei f5adee2
problem: unused addr.IsEmpty func
whilei e465063
problem: (refactor syntax) ugly 'removals' name collision
whilei 4837014
solution: optimize key slice with known length
whilei 42bf795
solution: merge to addr check conditional for eloquence
whilei 95f000f
solution: add comment explaining atxi db cache ratio for sync (vs build)
whilei 32505e2
problem: some addresses have lots of txs
whilei d69ac3b
problem: must ensure atxis are ordered by block number
whilei 6ac5a9a
solution: fix variable shadowing and empty slice by struct init
whilei efc2a42
problem: atxis returned are backward
whilei 2ec2a97
solution: move API debug_ -> geth_
whilei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package main | ||
|
||
import ( | ||
"gopkg.in/urfave/cli.v1" | ||
"strconv" | ||
"github.com/ethereumproject/go-ethereum/logger/glog" | ||
"github.com/ethereumproject/go-ethereum/core/types" | ||
"path/filepath" | ||
"io/ioutil" | ||
"os" | ||
"github.com/ethereumproject/go-ethereum/logger" | ||
"time" | ||
) | ||
|
||
func buildAddrTxIndexCmd(ctx *cli.Context) error { | ||
startIndex := uint64(ctx.Int("start")) | ||
var stopIndex uint64 | ||
|
||
// Use persistent placeholder in case start not spec'd | ||
placeholderFilename := filepath.Join(MustMakeChainDataDir(ctx), "index.at") | ||
if !ctx.IsSet("start") { | ||
bs, err := ioutil.ReadFile(placeholderFilename) | ||
if err == nil { // ignore errors for now | ||
startIndex, _ = strconv.ParseUint(string(bs), 10, 64) | ||
} | ||
} | ||
|
||
bc, chainDB := MakeChain(ctx) | ||
if bc == nil || chainDB == nil { | ||
panic("bc or cdb is nil") | ||
} | ||
defer chainDB.Close() | ||
|
||
stopIndex = uint64(ctx.Int("stop")) | ||
if stopIndex == 0 { | ||
stopIndex = bc.CurrentHeader().Number.Uint64() | ||
} | ||
|
||
if stopIndex < startIndex { | ||
glog.Fatal("start must be prior to (smaller than) or equal to stop, got start=", startIndex, "stop=", stopIndex) | ||
} | ||
if startIndex == stopIndex { | ||
glog.D(logger.Error).Infoln("Up to date. Exiting.") | ||
os.Exit(0) | ||
} | ||
|
||
indexDb := MakeIndexDatabase(ctx) | ||
if indexDb == nil { | ||
panic("indexdb is nil") | ||
} | ||
defer indexDb.Close() | ||
|
||
var block *types.Block | ||
blockIndex := startIndex | ||
block = bc.GetBlockByNumber(blockIndex) | ||
if block == nil { | ||
glog.Fatal(blockIndex, "block is nil") | ||
} | ||
|
||
var inc = uint64(ctx.Int("step")) | ||
startTime := time.Now() | ||
glog.D(logger.Error).Infoln("Address/tx indexing (atxi) start:", startIndex, "stop:", stopIndex, "step:", inc) | ||
for i := startIndex; i <= stopIndex; i = i+inc { | ||
if i+inc > stopIndex { | ||
inc = stopIndex - startIndex | ||
} | ||
if err := bc.AddTxIndexesBatch(indexDb, i, i+inc); err != nil { | ||
return err | ||
} | ||
ioutil.WriteFile(placeholderFilename, []byte(strconv.Itoa(int(i+inc))), os.ModePerm) | ||
} | ||
ioutil.WriteFile(placeholderFilename, []byte(strconv.Itoa(int(stopIndex))), os.ModePerm) | ||
glog.D(logger.Error).Infoln("Finished atxi. Took:", time.Since(startTime)) | ||
return nil | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you use
glog.Fatal
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.