From f5100f8f43e6ff341cf679f09660094b95e69e7d Mon Sep 17 00:00:00 2001 From: jmlee Date: Tue, 16 Jul 2019 16:09:25 +0900 Subject: [PATCH] add comments --- core/state/dump.go | 8 +++++--- node/service.go | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/state/dump.go b/core/state/dump.go index 76bf54984c..12909fed68 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -40,10 +40,10 @@ type DumpAccount struct { } -// Dump represents the full dump in a collected format, as one large map +// Dump represents the full state tire dump in a collected format, as one large map (jmlee) type Dump struct { - Root string `json:"root"` - Accounts map[common.Address]DumpAccount `json:"accounts"` + Root string `json:"root"` // state trie's root hash (jmlee) + Accounts map[common.Address]DumpAccount `json:"accounts"` // all accounts in state trie (jmlee) } // iterativeDump is a 'collector'-implementation which dump output line-by-line iteratively @@ -55,10 +55,12 @@ type collector interface { onAccount(common.Address, DumpAccount) } +// onRoot sets Dump.Root field (jmlee) func (self *Dump) onRoot(root common.Hash) { self.Root = fmt.Sprintf("%x", root) } +// onAccount inserts account into Dump.Accounts map field (jmlee) func (self *Dump) onAccount(addr common.Address, account DumpAccount) { self.Accounts[addr] = account } diff --git a/node/service.go b/node/service.go index 67dfe33d91..37e6e9c495 100644 --- a/node/service.go +++ b/node/service.go @@ -24,6 +24,7 @@ import ( "github.com/eth4nos/go-ethereum/core/rawdb" "github.com/eth4nos/go-ethereum/ethdb" "github.com/eth4nos/go-ethereum/event" + "github.com/eth4nos/go-ethereum/log" "github.com/eth4nos/go-ethereum/p2p" "github.com/eth4nos/go-ethereum/rpc" ) @@ -53,8 +54,13 @@ func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int, nam // also attaching a chain freezer to it that moves ancient chain data from the // database to immutable append-only files. If the node is an ephemeral one, a // memory database is returned. +// (if user set datadir, then open or load leveldb. if not, then open new memorydb) (jmlee) func (ctx *ServiceContext) OpenDatabaseWithFreezer(name string, cache int, handles int, freezer string, namespace string) (ethdb.Database, error) { + log.Info("\n### OpenDatabaseWithFreezer function executed ###\n") + log.Info("show params", "ctx.config.DataDir", ctx.config.DataDir, "freezer:", freezer) // (jmlee) + if ctx.config.DataDir == "" { + log.Info("### memory db opened!\n") // (jmlee) return rawdb.NewMemoryDatabase(), nil } root := ctx.config.ResolvePath(name)