diff --git a/.gitignore b/.gitignore index 3e0009e167..92bbd2d253 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,7 @@ profile.cov /dashboard/assets/package-lock.json **/yarn-error.log +$HOME + +# Remove Shyft Data +shyftData/* \ No newline at end of file diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index c9ab72b6df..8c8d7e70bc 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -146,6 +146,7 @@ Use "ethereum dump 0" to dump the genesis block.`, // initGenesis will initialise the given JSON format genesis file and writes it as // the zero'd block (i.e. genesis) or will fail hard if it can't succeed. func initGenesis(ctx *cli.Context) error { + fmt.Println("GENESIS+++++++++++++++++++++++") // Make sure we have a valid genesis JSON genesisPath := ctx.Args().First() if len(genesisPath) == 0 { @@ -314,7 +315,6 @@ func copyDb(ctx *cli.Context) error { syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode) dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil) - // Create a source peer to satisfy downloader requests from db, err := ethdb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256) if err != nil { diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 50e4de2e78..345835dea9 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -151,6 +151,7 @@ func enableWhisper(ctx *cli.Context) bool { } func makeFullNode(ctx *cli.Context) *node.Node { + fmt.Println("+++++++++++++++++cmd/geth/config.GO+++++++++++++++++++++++++MakeFullNode()") stack, cfg := makeConfigNode(ctx) utils.RegisterEthService(stack, &cfg.Eth) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index f5a3fa941a..00afce3308 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -214,6 +214,7 @@ func main() { // It creates a default node based on the command line arguments and runs it in // blocking mode, waiting for it to be shut down. func geth(ctx *cli.Context) error { + fmt.Println("+++++++++++++++++cmd/main/geth.GO+++++++++++++++++++++++++Geth()") node := makeFullNode(ctx) startNode(ctx, node) node.Wait() diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ff78a0fcc7..5c44161c5f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1122,6 +1122,7 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) { // RegisterEthService adds an Ethereum client to the stack. func RegisterEthService(stack *node.Node, cfg *eth.Config) { + fmt.Println("+++++++++++++++++cmd/utils/Flags.GO+++++++++++++++++++++++++RegisterEthService()") var err error if cfg.SyncMode == downloader.LightSync { err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { diff --git a/core/types/block.go b/core/types/block.go index 92b868d9da..8c0fff255a 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -200,7 +200,6 @@ type storageblock struct { // and receipts. func NewBlock(header *Header, txs []*Transaction, uncles []*Header, receipts []*Receipt) *Block { b := &Block{header: CopyHeader(header), td: new(big.Int)} - // TODO: panic if len(txs) != len(receipts) if len(txs) == 0 { b.header.TxHash = EmptyRootHash diff --git a/eth/backend.go b/eth/backend.go index 94aad23101..567bbb866b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -102,6 +102,7 @@ func (s *Ethereum) AddLesServer(ls LesServer) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { + fmt.Println("+++++++++++++++++eth/backend.GO+++++++++++++++++++++++++New()") if config.SyncMode == downloader.LightSync { return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum") } @@ -200,6 +201,7 @@ func makeExtraData(extra []byte) []byte { // CreateDB creates the chain database. func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { + fmt.Println("+++++++++++++++++eth/backend.GO+++++++++++++++++++++++++CreateDB()") db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) if err != nil { return nil, err @@ -228,6 +230,7 @@ func CreateConsensusEngine(ctx *node.ServiceContext, config *ethash.Config, chai log.Warn("Ethash used in shared mode") return ethash.NewShared() default: + log.Warn("Ethash used in POW") engine := ethash.New(ethash.Config{ CacheDir: ctx.ResolvePath(config.CacheDir), CachesInMem: config.CachesInMem, diff --git a/shyftData/geth/LOCK b/shyftData/geth/LOCK new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shyftData/geth/chaindata/000027.ldb b/shyftData/geth/chaindata/000027.ldb new file mode 100644 index 0000000000..84c9a3161d Binary files /dev/null and b/shyftData/geth/chaindata/000027.ldb differ diff --git a/shyftData/geth/chaindata/000028.ldb b/shyftData/geth/chaindata/000028.ldb new file mode 100644 index 0000000000..ba48cdfdc5 Binary files /dev/null and b/shyftData/geth/chaindata/000028.ldb differ diff --git a/shyftData/geth/chaindata/000031.ldb b/shyftData/geth/chaindata/000031.ldb new file mode 100644 index 0000000000..a504af6cc6 Binary files /dev/null and b/shyftData/geth/chaindata/000031.ldb differ diff --git a/shyftData/geth/chaindata/000034.ldb b/shyftData/geth/chaindata/000034.ldb new file mode 100644 index 0000000000..d0b8f490b5 Binary files /dev/null and b/shyftData/geth/chaindata/000034.ldb differ diff --git a/shyftData/geth/chaindata/000035.log b/shyftData/geth/chaindata/000035.log new file mode 100644 index 0000000000..78f59554a4 Binary files /dev/null and b/shyftData/geth/chaindata/000035.log differ diff --git a/shyftData/geth/chaindata/CURRENT b/shyftData/geth/chaindata/CURRENT new file mode 100644 index 0000000000..ecb0b4bcde --- /dev/null +++ b/shyftData/geth/chaindata/CURRENT @@ -0,0 +1 @@ +MANIFEST-000036 diff --git a/shyftData/geth/chaindata/LOCK b/shyftData/geth/chaindata/LOCK new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shyftData/geth/chaindata/LOG b/shyftData/geth/chaindata/LOG new file mode 100644 index 0000000000..a46e1674f8 --- /dev/null +++ b/shyftData/geth/chaindata/LOG @@ -0,0 +1,155 @@ +=============== Apr 13, 2018 (AST) =============== +12:04:04.151274 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:04:04.152576 db@open opening +12:04:04.153679 version@stat F·[] S·0B[] Sc·[] +12:04:04.153970 db@janitor F·2 G·0 +12:04:04.153998 db@open done T·1.404222ms +=============== Apr 13, 2018 (AST) =============== +12:04:04.245090 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:04:04.245293 version@stat F·[] S·0B[] Sc·[] +12:04:04.245316 db@open opening +12:04:04.245392 journal@recovery F·1 +12:04:04.248972 journal@recovery recovering @1 +12:04:04.251711 memdb@flush created L0@2 N·20 S·1KiB "H\xfa\x01..-\xaf\xd4,v14":"\xf12\n..\x13\x8b\xee,v10" +12:04:04.255210 version@stat F·[1] S·1KiB[1KiB] Sc·[0.25] +12:04:04.256371 db@janitor F·3 G·0 +12:04:04.256399 db@open done T·11.069642ms +12:04:09.017206 db@close closing +12:04:09.017511 db@close done T·303.15µs +=============== Apr 13, 2018 (AST) =============== +12:04:27.744882 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:04:27.745145 version@stat F·[1] S·1KiB[1KiB] Sc·[0.25] +12:04:27.745173 db@open opening +12:04:27.745250 journal@recovery F·1 +12:04:27.748910 journal@recovery recovering @3 +12:04:27.750343 memdb@flush created L0@5 N·3 S·290B "Blo..ion,v23":"dbU..ata,v22" +12:04:27.753715 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] +12:04:27.754866 db@janitor F·4 G·0 +12:04:27.754895 db@open done T·9.707082ms +12:04:29.948781 db@close closing +12:04:29.949012 db@close done T·228.745µs +=============== Apr 13, 2018 (AST) =============== +12:05:57.980961 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:05:57.981199 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] +12:05:57.981224 db@open opening +12:05:57.981288 journal@recovery F·1 +12:05:57.984785 journal@recovery recovering @6 +12:05:57.985528 memdb@flush created L0@8 N·2 S·243B "Blo..ion,v26":"Las..der,v27" +12:05:57.988994 version@stat F·[3] S·1KiB[1KiB] Sc·[0.75] +12:05:57.990242 db@janitor F·5 G·0 +12:05:57.990275 db@open done T·9.036549ms +12:06:04.901508 db@close closing +12:06:04.902195 db@close done T·683.506µs +=============== Apr 13, 2018 (AST) =============== +12:09:35.059752 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:09:35.059959 version@stat F·[3] S·1KiB[1KiB] Sc·[0.75] +12:09:35.059982 db@open opening +12:09:35.060049 journal@recovery F·1 +12:09:35.063500 journal@recovery recovering @9 +12:09:35.064291 memdb@flush created L0@11 N·31 S·1KiB "Blo..ion,v29":"\xf2\x06y..\x9b\xfc\xc1,v52" +12:09:35.070241 version@stat F·[4] S·3KiB[3KiB] Sc·[1.00] +12:09:35.071377 db@janitor F·6 G·0 +12:09:35.071403 db@open done T·11.408216ms +12:09:35.071479 table@compaction L0·4 -> L1·0 S·3KiB Q·60 +12:09:35.072134 table@build created L1@14 N·45 S·3KiB "Blo..ion,v29":"\xf2\x06y..\x9b\xfc\xc1,v52" +12:09:35.072185 version@stat F·[0 1] S·3KiB[0B 3KiB] Sc·[0.00 0.00] +12:09:35.072335 table@compaction committed F-3 S-608B Ke·0 D·11 T·814.987µs +12:09:35.072525 table@remove removed @11 +12:09:35.072646 table@remove removed @8 +12:09:35.072816 table@remove removed @5 +12:09:35.072928 table@remove removed @2 +12:09:39.226536 db@close closing +12:09:39.226742 db@close done T·205.679µs +=============== Apr 13, 2018 (AST) =============== +12:31:22.366128 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:31:22.366349 version@stat F·[0 1] S·3KiB[0B 3KiB] Sc·[0.00 0.00] +12:31:22.366374 db@open opening +12:31:22.366438 journal@recovery F·1 +12:31:22.370035 journal@recovery recovering @12 +12:31:22.370810 memdb@flush created L0@15 N·2 S·243B "Blo..ion,v61":"Las..der,v62" +12:31:22.375645 version@stat F·[1 1] S·3KiB[243B 3KiB] Sc·[0.25 0.00] +12:31:22.377234 db@janitor F·4 G·0 +12:31:22.377292 db@open done T·10.900867ms +12:31:29.207074 db@close closing +12:31:29.207418 db@close done T·341.87µs +=============== Apr 13, 2018 (AST) =============== +12:32:26.324179 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:32:26.324405 version@stat F·[1 1] S·3KiB[243B 3KiB] Sc·[0.25 0.00] +12:32:26.324430 db@open opening +12:32:26.324498 journal@recovery F·1 +12:32:26.328016 journal@recovery recovering @16 +12:32:26.328958 memdb@flush created L0@18 N·48 S·2KiB "\x16\x01\x03..f\b\x1f,v107":"\xfc\xab\x18..J\xdc\x1b,v105" +12:32:26.332454 version@stat F·[2 1] S·5KiB[2KiB 3KiB] Sc·[0.50 0.00] +12:32:26.333662 db@janitor F·5 G·0 +12:32:26.333695 db@open done T·9.249844ms +12:32:27.127291 db@close closing +12:32:27.127434 db@close done T·141.573µs +=============== Apr 13, 2018 (AST) =============== +12:32:53.391884 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:32:53.392154 version@stat F·[2 1] S·5KiB[2KiB 3KiB] Sc·[0.50 0.00] +12:32:53.392182 db@open opening +12:32:53.392258 journal@recovery F·1 +12:32:53.395717 journal@recovery recovering @19 +12:32:53.396537 memdb@flush created L0@21 N·2 S·243B "Blo..ion,v113":"Las..der,v114" +12:32:53.401216 version@stat F·[3 1] S·6KiB[3KiB 3KiB] Sc·[0.75 0.00] +12:32:53.402922 db@janitor F·6 G·0 +12:32:53.402985 db@open done T·10.784557ms +12:33:00.729948 db@close closing +12:33:00.730289 db@close done T·336.743µs +=============== Apr 13, 2018 (AST) =============== +12:35:26.038184 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:35:26.038429 version@stat F·[3 1] S·6KiB[3KiB 3KiB] Sc·[0.75 0.00] +12:35:26.038454 db@open opening +12:35:26.038526 journal@recovery F·1 +12:35:26.042038 journal@recovery recovering @22 +12:35:26.042963 memdb@flush created L0@24 N·39 S·1KiB "\x14\xa1\x86..y\a\xb7,v147":"\xf7\b\xdc../\xc4q,v148" +12:35:26.047598 version@stat F·[4 1] S·8KiB[5KiB 3KiB] Sc·[1.00 0.00] +12:35:26.048743 db@janitor F·7 G·0 +12:35:26.048824 db@open done T·10.327983ms +12:35:26.048913 table@compaction L0·4 -> L1·1 S·8KiB Q·155 +12:35:26.049968 table@build created L1@27 N·103 S·6KiB "\x14\xa1\x86..y\a\xb7,v147":"\xfc\xab\x18..J\xdc\x1b,v105" +12:35:26.050024 version@stat F·[0 1] S·6KiB[0B 6KiB] Sc·[0.00 0.00] +12:35:26.050188 table@compaction committed F-4 S-1KiB Ke·0 D·33 T·1.224726ms +12:35:26.050434 table@remove removed @24 +12:35:26.050565 table@remove removed @21 +12:35:26.050694 table@remove removed @18 +12:35:26.050820 table@remove removed @15 +12:35:26.050938 table@remove removed @14 +12:35:30.084448 db@close closing +12:35:30.084569 db@close done T·120.107µs +=============== Apr 13, 2018 (AST) =============== +12:38:00.862042 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:38:00.862304 version@stat F·[0 1] S·6KiB[0B 6KiB] Sc·[0.00 0.00] +12:38:00.862341 db@open opening +12:38:00.862434 journal@recovery F·1 +12:38:00.866077 journal@recovery recovering @25 +12:38:00.866852 memdb@flush created L0@28 N·2 S·243B "Blo..ion,v156":"Las..der,v157" +12:38:00.870308 version@stat F·[1 1] S·6KiB[243B 6KiB] Sc·[0.25 0.00] +12:38:00.871603 db@janitor F·4 G·0 +12:38:00.871664 db@open done T·9.282095ms +12:38:02.417010 db@close closing +12:38:02.417372 db@close done T·359.175µs +=============== Apr 13, 2018 (AST) =============== +12:38:06.632016 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:38:06.632261 version@stat F·[1 1] S·6KiB[243B 6KiB] Sc·[0.25 0.00] +12:38:06.632307 db@open opening +12:38:06.632813 journal@recovery F·1 +12:38:06.636170 journal@recovery recovering @29 +12:38:06.637883 memdb@flush created L0@31 N·2 S·243B "Blo..ion,v159":"Las..der,v160" +12:38:06.641325 version@stat F·[2 1] S·7KiB[486B 6KiB] Sc·[0.50 0.00] +12:38:06.642446 db@janitor F·5 G·0 +12:38:06.642477 db@open done T·10.121952ms +12:38:08.433076 db@close closing +12:38:08.433328 db@close done T·251.29µs +=============== Apr 13, 2018 (AST) =============== +12:38:46.567903 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:38:46.568574 version@stat F·[2 1] S·7KiB[486B 6KiB] Sc·[0.50 0.00] +12:38:46.568622 db@open opening +12:38:46.568734 journal@recovery F·1 +12:38:46.572110 journal@recovery recovering @32 +12:38:46.573004 memdb@flush created L0@34 N·2 S·243B "Blo..ion,v162":"Las..der,v163" +12:38:46.576760 version@stat F·[3 1] S·7KiB[729B 6KiB] Sc·[0.75 0.00] +12:38:46.578112 db@janitor F·6 G·0 +12:38:46.578169 db@open done T·9.508784ms +12:38:48.142763 db@close closing +12:38:48.143004 db@close done T·240.548µs diff --git a/shyftData/geth/chaindata/MANIFEST-000036 b/shyftData/geth/chaindata/MANIFEST-000036 new file mode 100644 index 0000000000..c09f7d3803 Binary files /dev/null and b/shyftData/geth/chaindata/MANIFEST-000036 differ diff --git a/shyftData/geth/lightchaindata/000001.log b/shyftData/geth/lightchaindata/000001.log new file mode 100644 index 0000000000..bd7aa305cf Binary files /dev/null and b/shyftData/geth/lightchaindata/000001.log differ diff --git a/shyftData/geth/lightchaindata/CURRENT b/shyftData/geth/lightchaindata/CURRENT new file mode 100644 index 0000000000..feda7d6b24 --- /dev/null +++ b/shyftData/geth/lightchaindata/CURRENT @@ -0,0 +1 @@ +MANIFEST-000000 diff --git a/shyftData/geth/lightchaindata/LOCK b/shyftData/geth/lightchaindata/LOCK new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shyftData/geth/lightchaindata/LOG b/shyftData/geth/lightchaindata/LOG new file mode 100644 index 0000000000..b8971e30d6 --- /dev/null +++ b/shyftData/geth/lightchaindata/LOG @@ -0,0 +1,6 @@ +=============== Apr 13, 2018 (AST) =============== +12:04:04.155040 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:04:04.155629 db@open opening +12:04:04.156233 version@stat F·[] S·0B[] Sc·[] +12:04:04.156560 db@janitor F·2 G·0 +12:04:04.156607 db@open done T·955.262µs diff --git a/shyftData/geth/lightchaindata/MANIFEST-000000 b/shyftData/geth/lightchaindata/MANIFEST-000000 new file mode 100644 index 0000000000..9d54f6733b Binary files /dev/null and b/shyftData/geth/lightchaindata/MANIFEST-000000 differ diff --git a/shyftData/geth/nodekey b/shyftData/geth/nodekey new file mode 100644 index 0000000000..4f8f507bb6 --- /dev/null +++ b/shyftData/geth/nodekey @@ -0,0 +1 @@ +2fee992ae9ac85c582badcfc0bb43d9ab2fb3db3ff2d27e211121ab72a040edd \ No newline at end of file diff --git a/shyftData/geth/nodes/000038.log b/shyftData/geth/nodes/000038.log new file mode 100644 index 0000000000..745ce0f388 Binary files /dev/null and b/shyftData/geth/nodes/000038.log differ diff --git a/shyftData/geth/nodes/000040.ldb b/shyftData/geth/nodes/000040.ldb new file mode 100644 index 0000000000..ea20fff178 Binary files /dev/null and b/shyftData/geth/nodes/000040.ldb differ diff --git a/shyftData/geth/nodes/CURRENT b/shyftData/geth/nodes/CURRENT new file mode 100644 index 0000000000..150cae32f7 --- /dev/null +++ b/shyftData/geth/nodes/CURRENT @@ -0,0 +1 @@ +MANIFEST-000039 diff --git a/shyftData/geth/nodes/LOCK b/shyftData/geth/nodes/LOCK new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shyftData/geth/nodes/LOG b/shyftData/geth/nodes/LOG new file mode 100644 index 0000000000..390f39982d --- /dev/null +++ b/shyftData/geth/nodes/LOG @@ -0,0 +1,182 @@ +=============== Apr 13, 2018 (AST) =============== +12:04:04.258528 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:04:04.259124 db@open opening +12:04:04.261595 version@stat F·[] S·0B[] Sc·[] +12:04:04.262107 db@janitor F·2 G·0 +12:04:04.262138 db@open done T·2.996906ms +12:04:09.025844 db@close closing +12:04:09.026093 db@close done T·247.236µs +=============== Apr 13, 2018 (AST) =============== +12:04:27.759840 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:04:27.761106 version@stat F·[] S·0B[] Sc·[] +12:04:27.761242 db@open opening +12:04:27.761444 journal@recovery F·1 +12:04:27.767821 journal@recovery recovering @1 +12:04:27.771507 memdb@flush created L0@2 N·525 S·18KiB "n:\x01..ail,v522":"version,v1" +12:04:27.775228 version@stat F·[1] S·18KiB[18KiB] Sc·[0.25] +12:04:27.776190 db@janitor F·3 G·0 +12:04:27.776224 db@open done T·14.941476ms +12:04:29.958195 db@close closing +12:04:29.958500 db@close done T·297.528µs +=============== Apr 13, 2018 (AST) =============== +12:05:57.994898 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:05:57.995072 version@stat F·[1] S·18KiB[18KiB] Sc·[0.25] +12:05:57.995093 db@open opening +12:05:57.995145 journal@recovery F·1 +12:05:57.997512 journal@recovery recovering @3 +12:05:57.998890 memdb@flush created L0@5 N·371 S·12KiB "n:\x01..ail,v673":"n:\xfb..ing,v796" +12:05:58.003221 version@stat F·[2] S·31KiB[31KiB] Sc·[0.50] +12:05:58.006015 db@janitor F·4 G·0 +12:05:58.006124 db@open done T·11.005925ms +12:05:58.556054 table@compaction L0·2 -> L1·0 S·31KiB Q·915 +12:05:58.558059 table@build created L1@8 N·674 S·28KiB "n:\x01..ail,v673":"version,v1" +12:05:58.558112 version@stat F·[0 1] S·28KiB[0B 28KiB] Sc·[0.00 0.00] +12:05:58.558297 table@compaction committed F-1 S-2KiB Ke·0 D·222 T·2.178957ms +12:05:58.558475 table@remove removed @5 +12:05:58.558626 table@remove removed @2 +12:06:04.902601 db@close closing +12:06:04.902982 db@close done T·378.92µs +=============== Apr 13, 2018 (AST) =============== +12:09:35.075185 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:09:35.075355 version@stat F·[0 1] S·28KiB[0B 28KiB] Sc·[0.00 0.00] +12:09:35.075376 db@open opening +12:09:35.075428 journal@recovery F·1 +12:09:35.077892 journal@recovery recovering @6 +12:09:35.080018 memdb@flush created L0@9 N·190 S·7KiB "n:\x00..ail,v993":"n:\xfb..ing,v1064" +12:09:35.085244 version@stat F·[1 1] S·35KiB[7KiB 28KiB] Sc·[0.25 0.00] +12:09:35.087000 db@janitor F·4 G·0 +12:09:35.087065 db@open done T·11.672302ms +12:09:35.472748 table@compaction L0·1 -> L1·1 S·35KiB Q·1107 +12:09:35.474982 table@build created L1@12 N·797 S·34KiB "n:\x00..ail,v993":"version,v1" +12:09:35.475036 version@stat F·[0 1] S·34KiB[0B 34KiB] Sc·[0.00 0.00] +12:09:35.475218 table@compaction committed F-1 S-1KiB Ke·0 D·67 T·2.423051ms +12:09:35.475393 table@remove removed @9 +12:09:35.475542 table@remove removed @8 +12:09:39.233198 db@close closing +12:09:39.233423 db@close done T·208.5µs +=============== Apr 13, 2018 (AST) =============== +12:31:22.379798 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:31:22.379974 version@stat F·[0 1] S·34KiB[0B 34KiB] Sc·[0.00 0.00] +12:31:22.379995 db@open opening +12:31:22.380049 journal@recovery F·1 +12:31:22.383024 journal@recovery recovering @10 +12:31:22.384630 memdb@flush created L0@13 N·460 S·15KiB "n:\x00..ail,v1365":"n:\xfe..ong,v1405" +12:31:22.389022 version@stat F·[1 1] S·50KiB[15KiB 34KiB] Sc·[0.25 0.00] +12:31:22.389977 db@janitor F·4 G·0 +12:31:22.390005 db@open done T·9.996252ms +12:31:23.539646 table@compaction L0·1 -> L1·1 S·50KiB Q·1579 +12:31:23.542358 table@build created L1@16 N·1108 S·46KiB "n:\x00..ail,v993":"version,v1" +12:31:23.542414 version@stat F·[0 1] S·46KiB[0B 46KiB] Sc·[0.00 0.00] +12:31:23.542591 table@compaction committed F-1 S-4KiB Ke·0 D·149 T·2.897433ms +12:31:23.542768 table@remove removed @13 +12:31:23.542914 table@remove removed @12 +12:31:29.215854 db@close closing +12:31:29.217470 db@close done T·1.610753ms +=============== Apr 13, 2018 (AST) =============== +12:32:26.338766 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:32:26.339071 version@stat F·[0 1] S·46KiB[0B 46KiB] Sc·[0.00 0.00] +12:32:26.339098 db@open opening +12:32:26.339169 journal@recovery F·1 +12:32:26.341472 journal@recovery recovering @14 +12:32:26.343067 memdb@flush created L0@17 N·501 S·17KiB "n:\x00..ail,v1868":"n:\xfd..ong,v1685" +12:32:26.346141 version@stat F·[1 1] S·63KiB[17KiB 46KiB] Sc·[0.25 0.00] +12:32:26.348948 db@janitor F·4 G·0 +12:32:26.349042 db@open done T·9.921404ms +12:32:27.061657 table@compaction L0·1 -> L1·1 S·63KiB Q·2069 +12:32:27.063977 table@build created L1@20 N·1403 S·60KiB "n:\x00..ail,v993":"version,v1" +12:32:27.064030 version@stat F·[0 1] S·60KiB[0B 60KiB] Sc·[0.00 0.00] +12:32:27.064184 table@compaction committed F-1 S-3KiB Ke·0 D·206 T·2.474847ms +12:32:27.064385 table@remove removed @17 +12:32:27.064532 table@remove removed @16 +12:32:27.129169 db@close closing +12:32:27.129359 db@close done T·187.563µs +=============== Apr 13, 2018 (AST) =============== +12:32:53.407267 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:32:53.407537 version@stat F·[0 1] S·60KiB[0B 60KiB] Sc·[0.00 0.00] +12:32:53.407570 db@open opening +12:32:53.407671 journal@recovery F·1 +12:32:53.409981 journal@recovery recovering @18 +12:32:53.410451 memdb@flush created L0@21 N·27 S·1KiB "n:\x11..ail,v2074":"n:\xea..ing,v2062" +12:32:53.412473 version@stat F·[1 1] S·61KiB[1KiB 60KiB] Sc·[0.25 0.00] +12:32:53.413365 db@janitor F·4 G·0 +12:32:53.413396 db@open done T·5.805523ms +12:32:53.830701 table@compaction L0·1 -> L1·1 S·61KiB Q·2096 +12:32:53.833581 table@build created L1@24 N·1404 S·60KiB "n:\x00..ail,v993":"version,v1" +12:32:53.833638 version@stat F·[0 1] S·60KiB[0B 60KiB] Sc·[0.00 0.00] +12:32:53.833831 table@compaction committed F-1 S-1KiB Ke·0 D·26 T·3.074384ms +12:32:53.834020 table@remove removed @21 +12:32:53.834201 table@remove removed @20 +12:33:00.737435 db@close closing +12:33:00.737665 db@close done T·228.329µs +=============== Apr 13, 2018 (AST) =============== +12:35:26.053650 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:35:26.053877 version@stat F·[0 1] S·60KiB[0B 60KiB] Sc·[0.00 0.00] +12:35:26.053908 db@open opening +12:35:26.053965 journal@recovery F·1 +12:35:26.055934 journal@recovery recovering @22 +12:35:26.057188 memdb@flush created L0@25 N·493 S·18KiB "n:\x02..ing,v2412":"n:\xff..ing,v2375" +12:35:26.061589 version@stat F·[1 1] S·78KiB[18KiB 60KiB] Sc·[0.25 0.00] +12:35:26.062656 db@janitor F·4 G·0 +12:35:26.062690 db@open done T·8.7682ms +12:35:26.429876 table@compaction L0·1 -> L1·1 S·78KiB Q·2580 +12:35:26.433304 table@build created L1@28 N·1659 S·73KiB "n:\x00..ail,v993":"version,v1" +12:35:26.433376 version@stat F·[0 1] S·73KiB[0B 73KiB] Sc·[0.00 0.00] +12:35:26.433587 table@compaction committed F-1 S-5KiB Ke·0 D·238 T·3.649989ms +12:35:26.433767 table@remove removed @25 +12:35:26.433918 table@remove removed @24 +12:35:30.092116 db@close closing +12:35:30.092386 db@close done T·270.679µs +=============== Apr 13, 2018 (AST) =============== +12:38:00.874997 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:38:00.875242 version@stat F·[0 1] S·73KiB[0B 73KiB] Sc·[0.00 0.00] +12:38:00.875269 db@open opening +12:38:00.875333 journal@recovery F·1 +12:38:00.878605 journal@recovery recovering @26 +12:38:00.880214 memdb@flush created L0@29 N·366 S·12KiB "n:\x03..ail,v2928":"n:\xf6..ong,v2651" +12:38:00.882313 version@stat F·[1 1] S·85KiB[12KiB 73KiB] Sc·[0.25 0.00] +12:38:00.883256 db@janitor F·4 G·0 +12:38:00.883286 db@open done T·8.001459ms +12:38:01.290611 table@compaction L0·1 -> L1·1 S·85KiB Q·2954 +12:38:01.293746 table@build created L1@32 N·1875 S·82KiB "n:\x00..ail,v993":"version,v1" +12:38:01.293789 version@stat F·[0 1] S·82KiB[0B 82KiB] Sc·[0.00 0.00] +12:38:01.293942 table@compaction committed F-1 S-3KiB Ke·0 D·150 T·3.291485ms +12:38:01.294122 table@remove removed @29 +12:38:01.294264 table@remove removed @28 +12:38:02.427055 db@close closing +12:38:02.427243 db@close done T·184.061µs +=============== Apr 13, 2018 (AST) =============== +12:38:06.645049 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:38:06.645213 version@stat F·[0 1] S·82KiB[0B 82KiB] Sc·[0.00 0.00] +12:38:06.645235 db@open opening +12:38:06.645288 journal@recovery F·1 +12:38:06.648615 journal@recovery recovering @30 +12:38:06.651553 memdb@flush created L0@33 N·156 S·5KiB "n:\a..ing,v3017":"n:\xf6..ong,v3004" +12:38:06.655273 version@stat F·[1 1] S·87KiB[5KiB 82KiB] Sc·[0.25 0.00] +12:38:06.656339 db@janitor F·4 G·0 +12:38:06.656396 db@open done T·11.145345ms +12:38:07.020845 table@compaction L0·1 -> L1·1 S·87KiB Q·3108 +12:38:07.024207 table@build created L1@36 N·1900 S·84KiB "n:\x00..ail,v993":"version,v1" +12:38:07.024273 version@stat F·[0 1] S·84KiB[0B 84KiB] Sc·[0.00 0.00] +12:38:07.024463 table@compaction committed F-1 S-3KiB Ke·0 D·131 T·3.54377ms +12:38:07.024648 table@remove removed @33 +12:38:07.024807 table@remove removed @32 +12:38:08.441630 db@close closing +12:38:08.441867 db@close done T·237.18µs +=============== Apr 13, 2018 (AST) =============== +12:38:46.582000 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +12:38:46.582222 version@stat F·[0 1] S·84KiB[0B 84KiB] Sc·[0.00 0.00] +12:38:46.582245 db@open opening +12:38:46.582302 journal@recovery F·1 +12:38:46.585053 journal@recovery recovering @34 +12:38:46.586894 memdb@flush created L0@37 N·207 S·7KiB "n:\x02..ing,v3202":"n:\xfa..ing,v3249" +12:38:46.589655 version@stat F·[1 1] S·91KiB[7KiB 84KiB] Sc·[0.25 0.00] +12:38:46.590915 db@janitor F·4 G·0 +12:38:46.590955 db@open done T·8.694345ms +12:38:47.944401 table@compaction L0·1 -> L1·1 S·91KiB Q·3321 +12:38:47.948081 table@build created L1@40 N·2001 S·89KiB "n:\x00..ail,v993":"version,v1" +12:38:47.948135 version@stat F·[0 1] S·89KiB[0B 89KiB] Sc·[0.00 0.00] +12:38:47.948309 table@compaction committed F-1 S-2KiB Ke·0 D·106 T·3.855123ms +12:38:47.948489 table@remove removed @37 +12:38:47.948654 table@remove removed @36 +12:38:48.143756 db@close closing +12:38:48.143928 db@close done T·170.604µs diff --git a/shyftData/geth/nodes/MANIFEST-000039 b/shyftData/geth/nodes/MANIFEST-000039 new file mode 100644 index 0000000000..705b39bdf2 Binary files /dev/null and b/shyftData/geth/nodes/MANIFEST-000039 differ diff --git a/shyftData/geth/transactions.rlp b/shyftData/geth/transactions.rlp new file mode 100755 index 0000000000..e69de29bb2 diff --git a/shyftDb/database.go b/shyftDb/database.go new file mode 100644 index 0000000000..8c557e4820 --- /dev/null +++ b/shyftDb/database.go @@ -0,0 +1,383 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package ethdb + +import ( + "strconv" + "strings" + "sync" + "time" + + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/syndtr/goleveldb/leveldb" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" +) + +var OpenFileLimit = 64 + +type LDBDatabase struct { + fn string // filename for reporting + db *leveldb.DB // LevelDB instance + + compTimeMeter metrics.Meter // Meter for measuring the total time spent in database compaction + compReadMeter metrics.Meter // Meter for measuring the data read during compaction + compWriteMeter metrics.Meter // Meter for measuring the data written during compaction + diskReadMeter metrics.Meter // Meter for measuring the effective amount of data read + diskWriteMeter metrics.Meter // Meter for measuring the effective amount of data written + + quitLock sync.Mutex // Mutex protecting the quit channel access + quitChan chan chan error // Quit channel to stop the metrics collection before closing the database + + log log.Logger // Contextual logger tracking the database path +} + +// NewLDBDatabase returns a LevelDB wrapped object. +func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error) { + logger := log.New("database", file) + + // Ensure we have some minimal caching and file guarantees + if cache < 16 { + cache = 16 + } + if handles < 16 { + handles = 16 + } + logger.Info("Allocated cache and file handles", "cache", cache, "handles", handles) + + // Open the db and recover any potential corruptions + db, err := leveldb.OpenFile(file, &opt.Options{ + OpenFilesCacheCapacity: handles, + BlockCacheCapacity: cache / 2 * opt.MiB, + WriteBuffer: cache / 4 * opt.MiB, // Two of these are used internally + Filter: filter.NewBloomFilter(10), + }) + if _, corrupted := err.(*errors.ErrCorrupted); corrupted { + db, err = leveldb.RecoverFile(file, nil) + } + // (Re)check for errors and abort if opening of the db failed + if err != nil { + return nil, err + } + return &LDBDatabase{ + fn: file, + db: db, + log: logger, + }, nil +} + +// Path returns the path to the database directory. +func (db *LDBDatabase) Path() string { + return db.fn +} + +// Put puts the given key / value to the queue +func (db *LDBDatabase) Put(key []byte, value []byte) error { + // Generate the data to write to disk, update the meter and write + //value = rle.Compress(value) + + return db.db.Put(key, value, nil) +} + +func (db *LDBDatabase) Has(key []byte) (bool, error) { + return db.db.Has(key, nil) +} + +// Get returns the given key if it's present. +func (db *LDBDatabase) Get(key []byte) ([]byte, error) { + // Retrieve the key and increment the miss counter if not found + dat, err := db.db.Get(key, nil) + if err != nil { + return nil, err + } + return dat, nil + //return rle.Decompress(dat) +} + +// Delete deletes the key from the queue and database +func (db *LDBDatabase) Delete(key []byte) error { + // Execute the actual operation + return db.db.Delete(key, nil) +} + +func (db *LDBDatabase) NewIterator() iterator.Iterator { + return db.db.NewIterator(nil, nil) +} + +func (db *LDBDatabase) Close() { + // Stop the metrics collection to avoid internal database races + db.quitLock.Lock() + defer db.quitLock.Unlock() + + if db.quitChan != nil { + errc := make(chan error) + db.quitChan <- errc + if err := <-errc; err != nil { + db.log.Error("Metrics collection failed", "err", err) + } + } + err := db.db.Close() + if err == nil { + db.log.Info("Database closed") + } else { + db.log.Error("Failed to close database", "err", err) + } +} + +func (db *LDBDatabase) LDB() *leveldb.DB { + return db.db +} + +// Meter configures the database metrics collectors and +func (db *LDBDatabase) Meter(prefix string) { + // Short circuit metering if the metrics system is disabled + if !metrics.Enabled { + return + } + // Initialize all the metrics collector at the requested prefix + db.compTimeMeter = metrics.NewRegisteredMeter(prefix+"compact/time", nil) + db.compReadMeter = metrics.NewRegisteredMeter(prefix+"compact/input", nil) + db.compWriteMeter = metrics.NewRegisteredMeter(prefix+"compact/output", nil) + db.diskReadMeter = metrics.NewRegisteredMeter(prefix+"disk/read", nil) + db.diskWriteMeter = metrics.NewRegisteredMeter(prefix+"disk/write", nil) + + // Create a quit channel for the periodic collector and run it + db.quitLock.Lock() + db.quitChan = make(chan chan error) + db.quitLock.Unlock() + + go db.meter(3 * time.Second) +} + +// meter periodically retrieves internal leveldb counters and reports them to +// the metrics subsystem. +// +// This is how a stats table look like (currently): +// Compactions +// Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB) +// -------+------------+---------------+---------------+---------------+--------------- +// 0 | 0 | 0.00000 | 1.27969 | 0.00000 | 12.31098 +// 1 | 85 | 109.27913 | 28.09293 | 213.92493 | 214.26294 +// 2 | 523 | 1000.37159 | 7.26059 | 66.86342 | 66.77884 +// 3 | 570 | 1113.18458 | 0.00000 | 0.00000 | 0.00000 +// +// This is how the iostats look like (currently): +// Read(MB):3895.04860 Write(MB):3654.64712 +func (db *LDBDatabase) meter(refresh time.Duration) { + // Create the counters to store current and previous compaction values + compactions := make([][]float64, 2) + for i := 0; i < 2; i++ { + compactions[i] = make([]float64, 3) + } + // Create storage for iostats. + var iostats [2]float64 + // Iterate ad infinitum and collect the stats + for i := 1; ; i++ { + // Retrieve the database stats + stats, err := db.db.GetProperty("leveldb.stats") + if err != nil { + db.log.Error("Failed to read database stats", "err", err) + return + } + // Find the compaction table, skip the header + lines := strings.Split(stats, "\n") + for len(lines) > 0 && strings.TrimSpace(lines[0]) != "Compactions" { + lines = lines[1:] + } + if len(lines) <= 3 { + db.log.Error("Compaction table not found") + return + } + lines = lines[3:] + + // Iterate over all the table rows, and accumulate the entries + for j := 0; j < len(compactions[i%2]); j++ { + compactions[i%2][j] = 0 + } + for _, line := range lines { + parts := strings.Split(line, "|") + if len(parts) != 6 { + break + } + for idx, counter := range parts[3:] { + value, err := strconv.ParseFloat(strings.TrimSpace(counter), 64) + if err != nil { + db.log.Error("Compaction entry parsing failed", "err", err) + return + } + compactions[i%2][idx] += value + } + } + // Update all the requested meters + if db.compTimeMeter != nil { + db.compTimeMeter.Mark(int64((compactions[i%2][0] - compactions[(i-1)%2][0]) * 1000 * 1000 * 1000)) + } + if db.compReadMeter != nil { + db.compReadMeter.Mark(int64((compactions[i%2][1] - compactions[(i-1)%2][1]) * 1024 * 1024)) + } + if db.compWriteMeter != nil { + db.compWriteMeter.Mark(int64((compactions[i%2][2] - compactions[(i-1)%2][2]) * 1024 * 1024)) + } + + // Retrieve the database iostats. + ioStats, err := db.db.GetProperty("leveldb.iostats") + if err != nil { + db.log.Error("Failed to read database iostats", "err", err) + return + } + parts := strings.Split(ioStats, " ") + if len(parts) < 2 { + db.log.Error("Bad syntax of ioStats", "ioStats", ioStats) + return + } + r := strings.Split(parts[0], ":") + if len(r) < 2 { + db.log.Error("Bad syntax of read entry", "entry", parts[0]) + return + } + read, err := strconv.ParseFloat(r[1], 64) + if err != nil { + db.log.Error("Read entry parsing failed", "err", err) + return + } + w := strings.Split(parts[1], ":") + if len(w) < 2 { + db.log.Error("Bad syntax of write entry", "entry", parts[1]) + return + } + write, err := strconv.ParseFloat(w[1], 64) + if err != nil { + db.log.Error("Write entry parsing failed", "err", err) + return + } + if db.diskReadMeter != nil { + db.diskReadMeter.Mark(int64((read - iostats[0]) * 1024 * 1024)) + } + if db.diskWriteMeter != nil { + db.diskWriteMeter.Mark(int64((write - iostats[1]) * 1024 * 1024)) + } + iostats[0] = read + iostats[1] = write + + // Sleep a bit, then repeat the stats collection + select { + case errc := <-db.quitChan: + // Quit requesting, stop hammering the database + errc <- nil + return + + case <-time.After(refresh): + // Timeout, gather a new set of stats + } + } +} + +func (db *LDBDatabase) NewBatch() Batch { + return &ldbBatch{db: db.db, b: new(leveldb.Batch)} +} + +type ldbBatch struct { + db *leveldb.DB + b *leveldb.Batch + size int +} + +func (b *ldbBatch) Put(key, value []byte) error { + b.b.Put(key, value) + b.size += len(value) + return nil +} + +func (b *ldbBatch) Write() error { + return b.db.Write(b.b, nil) +} + +func (b *ldbBatch) ValueSize() int { + return b.size +} + +func (b *ldbBatch) Reset() { + b.b.Reset() + b.size = 0 +} + +type table struct { + db Database + prefix string +} + +// NewTable returns a Database object that prefixes all keys with a given +// string. +func NewTable(db Database, prefix string) Database { + return &table{ + db: db, + prefix: prefix, + } +} + +func (dt *table) Put(key []byte, value []byte) error { + return dt.db.Put(append([]byte(dt.prefix), key...), value) +} + +func (dt *table) Has(key []byte) (bool, error) { + return dt.db.Has(append([]byte(dt.prefix), key...)) +} + +func (dt *table) Get(key []byte) ([]byte, error) { + return dt.db.Get(append([]byte(dt.prefix), key...)) +} + +func (dt *table) Delete(key []byte) error { + return dt.db.Delete(append([]byte(dt.prefix), key...)) +} + +func (dt *table) Close() { + // Do nothing; don't close the underlying DB. +} + +type tableBatch struct { + batch Batch + prefix string +} + +// NewTableBatch returns a Batch object which prefixes all keys with a given string. +func NewTableBatch(db Database, prefix string) Batch { + return &tableBatch{db.NewBatch(), prefix} +} + +func (dt *table) NewBatch() Batch { + return &tableBatch{dt.db.NewBatch(), dt.prefix} +} + +func (tb *tableBatch) Put(key, value []byte) error { + return tb.batch.Put(append([]byte(tb.prefix), key...), value) +} + +func (tb *tableBatch) Write() error { + return tb.batch.Write() +} + +func (tb *tableBatch) ValueSize() int { + return tb.batch.ValueSize() +} + +func (tb *tableBatch) Reset() { + tb.batch.Reset() +} diff --git a/shyftDb/interface.go b/shyftDb/interface.go new file mode 100644 index 0000000000..bee33de2a8 --- /dev/null +++ b/shyftDb/interface.go @@ -0,0 +1,31 @@ + +package ethdb + +// Code using batches should try to add this much data to the batch. +// The value was determined empirically. +const IdealBatchSize = 100 * 1024 + +// Putter wraps the database write operation supported by both batches and regular databases. +type Putter interface { + Put(key []byte, value []byte) error +} + +// Database wraps all database operations. All methods are safe for concurrent use. +type Database interface { + Putter + Get(key []byte) ([]byte, error) + Has(key []byte) (bool, error) + Delete(key []byte) error + Close() + NewBatch() Batch +} + +// Batch is a write-only database that commits changes to its host database +// when Write is called. Batch cannot be used concurrently. +type Batch interface { + Putter + ValueSize() int // amount of data in the batch + Write() error + // Reset resets the batch for reuse + Reset() +} diff --git a/swarm/storage/dbstore.go b/swarm/storage/dbstore.go index 421bb061d5..42a0e5a8a6 100644 --- a/swarm/storage/dbstore.go +++ b/swarm/storage/dbstore.go @@ -88,7 +88,6 @@ func NewDbStore(path string, hash SwarmHasher, capacity uint64, radius int) (s * s = new(DbStore) s.hashfunc = hash - s.db, err = NewLDBDatabase(path) if err != nil { return