Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Skeleton of Ethermint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Akhunov committed Jun 13, 2018
1 parent 6d7bd6a commit e7be488
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 0 deletions.
157 changes: 157 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true

[[constraint]]
name = "github.com/tendermint/iavl"
version = "0.8.0-rc0"

[prune]
go-tests = true
92 changes: 92 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package main

import (
"fmt"

eth_common "github.com/ethereum/go-ethereum/common"
eth_state "github.com/ethereum/go-ethereum/core/state"
eth_ethdb "github.com/ethereum/go-ethereum/ethdb"
eth_trie "github.com/ethereum/go-ethereum/trie"

dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/iavl"
)

// Implementation of eth_state.Database
type OurDatabase struct {
tree *iavl.Tree
}

func OurNewDatabase(db dbm.DB, cacheSize int) *OurDatabase {
od := &OurDatabase{}
od.tree = iavl.NewTree(db, cacheSize)
return od
}

func (od *OurDatabase) OpenTrie(root eth_common.Hash) (eth_state.Trie, error) {
return &OurTrie{}, nil
}

func (od *OurDatabase) OpenStorageTrie(addrHash, root eth_common.Hash) (eth_state.Trie, error) {
return nil, nil
}

func (od *OurDatabase) CopyTrie(eth_state.Trie) eth_state.Trie {
return nil
}

func (od *OurDatabase) ContractCode(addrHash, codeHash eth_common.Hash) ([]byte, error) {
return nil, nil
}

func (od *OurDatabase) ContractCodeSize(addrHash, codeHash eth_common.Hash) (int, error) {
return 0, nil
}

func (od *OurDatabase) TrieDB() *eth_trie.Database {
return nil
}

// Implementation of eth_state.Trie
type OurTrie struct {
}

func (ot *OurTrie) TryGet(key []byte) ([]byte, error) {
return nil, nil
}

func (ot *OurTrie) TryUpdate(key, value []byte) error {
return nil
}

func (ot *OurTrie) TryDelete(key []byte) error {
return nil
}

func (ot *OurTrie) Commit(onleaf eth_trie.LeafCallback) (eth_common.Hash, error) {
return eth_common.Hash{}, nil
}

func (ot *OurTrie) Hash() eth_common.Hash {
return eth_common.Hash{}
}

func (ot *OurTrie) NodeIterator(startKey []byte) eth_trie.NodeIterator {
return nil
}

func (ot *OurTrie) GetKey([]byte) []byte {
return nil
}

func (ot *OurTrie) Prove(key []byte, fromLevel uint, proofDb eth_ethdb.Putter) error {
return nil
}

func main() {
fmt.Printf("Instantiating state.Database\n")
db := dbm.NewDB("test" /* name */, dbm.MemDBBackend, "" /* dir */)
var d eth_state.Database
d = OurNewDatabase(db, 1024)
d.OpenTrie(eth_common.Hash{})
}

0 comments on commit e7be488

Please sign in to comment.