diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index e069411160..b2904e811d 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -28,7 +28,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go
index 36986cdc7b..8dfd10671d 100644
--- a/cmd/geth/blocktestcmd.go
+++ b/cmd/geth/blocktestcmd.go
@@ -22,7 +22,7 @@ import (
"github.com/codegangsta/cli"
"github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/tests"
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 2de3002f90..50a2746aee 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 32200670fd..210565c6f4 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -34,7 +34,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 5128dcc28a..b249a56785 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -35,7 +35,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
diff --git a/core/bench_test.go b/core/bench_test.go
index 704e6a0ad4..4ab8858e49 100644
--- a/core/bench_test.go
+++ b/core/bench_test.go
@@ -24,7 +24,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/block_processor.go b/core/block_processor.go
index d4a9ee3b52..2e692f7374 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -23,7 +23,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
diff --git a/core/block_processor_test.go b/core/block_processor_test.go
index 46c3cd6c99..c90e25f0c7 100644
--- a/core/block_processor_test.go
+++ b/core/block_processor_test.go
@@ -22,7 +22,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
diff --git a/core/blockchain.go b/core/blockchain.go
index 43e7ed530d..c669cf8b9a 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -32,7 +32,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/core/blockchain_test.go b/core/blockchain_test.go
index 975d0c981b..243b5efa8a 100644
--- a/core/blockchain_test.go
+++ b/core/blockchain_test.go
@@ -28,7 +28,7 @@ import (
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/core/chain_makers.go b/core/chain_makers.go
index 2fd107324a..c207caa900 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -21,7 +21,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go
index b391118f70..ee25035e9e 100644
--- a/core/chain_makers_test.go
+++ b/core/chain_makers_test.go
@@ -20,7 +20,7 @@ import (
"fmt"
"math/big"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/chain_util.go b/core/chain_util.go
index 0b1f8e95bc..410d281b56 100644
--- a/core/chain_util.go
+++ b/core/chain_util.go
@@ -23,7 +23,8 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
+ "github.com/ethereum/go-ethereum/les/requests"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
@@ -186,9 +187,9 @@ func GetHeader(db ethdb.Database, hash common.Hash) *types.Header {
// GetBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
func GetBodyRLP(ca *access.ChainAccess, hash common.Hash, ctx *access.OdrContext) rlp.RawValue {
//fmt.Println("request block %v", hash)
- r := NewBlockAccess(ca.Db(), hash)
+ r := requests.NewBlockAccess(ca.Db(), hash, GetHeader)
ca.Retrieve(r, ctx)
- return r.rlp
+ return r.GetRlp()
}
// GetBody retrieves the block body (transactons, uncles) corresponding to the
diff --git a/core/chain_util_test.go b/core/chain_util_test.go
index 522d4b528a..5b108f43f5 100644
--- a/core/chain_util_test.go
+++ b/core/chain_util_test.go
@@ -24,7 +24,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/core/genesis.go b/core/genesis.go
index ff5ec73159..25ef63847a 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -25,7 +25,7 @@ import (
"strings"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/manager.go b/core/manager.go
index c2dbe8bfef..acdc7dc2e6 100644
--- a/core/manager.go
+++ b/core/manager.go
@@ -18,7 +18,7 @@ package core
import (
"github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
)
diff --git a/core/state/dump.go b/core/state/dump.go
index 173edc847b..37b06a48bb 100644
--- a/core/state/dump.go
+++ b/core/state/dump.go
@@ -21,7 +21,7 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
)
type Account struct {
diff --git a/core/state/managed_state.go b/core/state/managed_state.go
index 1a1e7e4909..a250b550df 100644
--- a/core/state/managed_state.go
+++ b/core/state/managed_state.go
@@ -20,7 +20,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
)
type account struct {
diff --git a/core/state/managed_state_test.go b/core/state/managed_state_test.go
index 8910bea4c6..a8e0582038 100644
--- a/core/state/managed_state_test.go
+++ b/core/state/managed_state_test.go
@@ -20,7 +20,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/ethdb"
)
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 27897b1dc8..9b5c08df4f 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -22,7 +22,8 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
+ "github.com/ethereum/go-ethereum/les/requests"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@@ -102,7 +103,7 @@ func NewStateObjectFromBytes(address common.Address, data []byte, ca *access.Cha
glog.Errorf("can't decode state object %x: %v", address, err)
return nil
}
- trie, err := trie.NewSecure(extobject.Root, ca.Db(), NewTrieAccess(ca, extobject.Root, ca.Db()))
+ trie, err := trie.NewSecure(extobject.Root, ca.Db(), requests.NewTrieAccess(ca, extobject.Root, ca.Db()))
if err != nil {
// TODO: bubble this up or panic
glog.Errorf("can't create account trie with root %x: %v", extobject.Root[:], err)
@@ -115,7 +116,7 @@ func NewStateObjectFromBytes(address common.Address, data []byte, ca *access.Cha
object.codeHash = extobject.CodeHash
object.trie = trie
object.storage = make(map[string]common.Hash)
- object.code = RetrieveNodeData(ca, common.BytesToHash(extobject.CodeHash), ctx)
+ object.code = requests.RetrieveNodeData(ca, common.BytesToHash(extobject.CodeHash), ctx)
return object
}
diff --git a/core/state/state_test.go b/core/state/state_test.go
index ba4b085bab..04d62451e8 100644
--- a/core/state/state_test.go
+++ b/core/state/state_test.go
@@ -24,7 +24,7 @@ import (
checker "gopkg.in/check.v1"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/ethdb"
)
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 152335e2c9..a6de7fe170 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -22,7 +22,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
+ "github.com/ethereum/go-ethereum/les/requests"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@@ -56,7 +57,7 @@ type StateDB struct {
// Create a new state from a given trie
// When ODR is used, context is specified when creating/copying a state.
func New(root common.Hash, ca *access.ChainAccess, ctx *access.OdrContext) (*StateDB, error) {
- tr, err := trie.NewSecure(root, ca.Db(), NewTrieAccess(ca, root, ca.Db()))
+ tr, err := trie.NewSecure(root, ca.Db(), requests.NewTrieAccess(ca, root, ca.Db()))
if err != nil {
glog.Errorf("can't create state trie with root %x: %v", root[:], err)
return nil, err
diff --git a/core/state/sync_test.go b/core/state/sync_test.go
index 8f6196556c..32e8e189f5 100644
--- a/core/state/sync_test.go
+++ b/core/state/sync_test.go
@@ -22,7 +22,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/trie"
)
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go
index c419192c30..abe0c8b0af 100644
--- a/core/transaction_pool_test.go
+++ b/core/transaction_pool_test.go
@@ -22,7 +22,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/core/transaction_util.go b/core/transaction_util.go
index 8b4550e577..7d514b35b3 100644
--- a/core/transaction_util.go
+++ b/core/transaction_util.go
@@ -20,7 +20,8 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
+ "github.com/ethereum/go-ethereum/les/requests"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
@@ -140,9 +141,9 @@ func GetReceipt(ca *access.ChainAccess, txHash common.Hash, ctx *access.OdrConte
// GetBlockReceipts returns the receipts generated by the transactions
// included in block's given hash.
func GetBlockReceipts(ca *access.ChainAccess, hash common.Hash, ctx *access.OdrContext) types.Receipts {
- r := NewReceiptsAccess(ca.Db(), hash)
+ r := requests.NewReceiptsAccess(ca.Db(), hash, GetHeader, PutReceipts, PutBlockReceipts)
ca.Retrieve(r, ctx)
- return r.receipts
+ return r.GetReceipts()
}
// PutBlockReceipts stores the block's transactions associated receipts
diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go
index cfee56599f..07d3080d3d 100644
--- a/core/types/derive_sha.go
+++ b/core/types/derive_sha.go
@@ -20,7 +20,7 @@ import (
"bytes"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
diff --git a/core/vm_env.go b/core/vm_env.go
index be9d993bcb..7bd6bdd511 100644
--- a/core/vm_env.go
+++ b/core/vm_env.go
@@ -20,7 +20,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
diff --git a/eth/backend.go b/eth/backend.go
index fb574b12f4..6ca2b0899b 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -38,7 +38,7 @@ import (
"github.com/ethereum/go-ethereum/common/httpclient"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/eth/backend_test.go b/eth/backend_test.go
index fdabf4d64e..9c7d9cdeee 100644
--- a/eth/backend_test.go
+++ b/eth/backend_test.go
@@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index 13e2d8d53f..9602ba8ec4 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index 609ea36eae..8902c4400b 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -21,7 +21,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/eth/gasprice.go b/eth/gasprice.go
index 3bf6adeef4..6a46e7f2cb 100644
--- a/eth/gasprice.go
+++ b/eth/gasprice.go
@@ -22,7 +22,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
diff --git a/eth/handler.go b/eth/handler.go
index 09496db974..3a5c6717da 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -26,7 +26,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/eth/fetcher"
diff --git a/eth/handler_test.go b/eth/handler_test.go
index c976a9b793..f78b57b953 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/eth/helper_test.go b/eth/helper_test.go
index 1057016fbc..6832f25293 100644
--- a/eth/helper_test.go
+++ b/eth/helper_test.go
@@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/core/access/chain_access.go b/les/access/chain_access.go
similarity index 100%
rename from core/access/chain_access.go
rename to les/access/chain_access.go
diff --git a/core/access/context.go b/les/access/context.go
similarity index 100%
rename from core/access/context.go
rename to les/access/context.go
diff --git a/core/access/peer.go b/les/access/peer.go
similarity index 100%
rename from core/access/peer.go
rename to les/access/peer.go
diff --git a/les/handler.go b/les/handler.go
index aa3acf28a8..9af619bfd1 100644
--- a/les/handler.go
+++ b/les/handler.go
@@ -25,9 +25,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
+ "github.com/ethereum/go-ethereum/les/access"
//"github.com/ethereum/go-ethereum/eth/fetcher"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
diff --git a/les/handler_test.go b/les/handler_test.go
index f6ad065422..667e6e6858 100644
--- a/les/handler_test.go
+++ b/les/handler_test.go
@@ -7,12 +7,12 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/trie"
)
diff --git a/les/helper_test.go b/les/helper_test.go
index b3510ba828..d008968b71 100644
--- a/les/helper_test.go
+++ b/les/helper_test.go
@@ -11,14 +11,14 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/params"
)
var (
diff --git a/les/odr_test.go b/les/odr_test.go
index 4fdeea292d..8acd34252d 100644
--- a/les/odr_test.go
+++ b/les/odr_test.go
@@ -8,8 +8,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/core/state"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
diff --git a/les/peer.go b/les/peer.go
index f997330529..3bc7b73948 100644
--- a/les/peer.go
+++ b/les/peer.go
@@ -24,8 +24,8 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
diff --git a/les/access_test.go b/les/request_test.go
similarity index 83%
rename from les/access_test.go
rename to les/request_test.go
index 5c9b0afd58..e821925327 100644
--- a/les/access_test.go
+++ b/les/request_test.go
@@ -6,9 +6,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
- "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/crypto/sha3"
+ "github.com/ethereum/go-ethereum/les/access"
+ "github.com/ethereum/go-ethereum/les/requests"
)
var testBankSecureTrieKey = secAddr(testBankAddress)
@@ -19,31 +19,30 @@ func secAddr(addr common.Address) []byte {
return sha.Sum(nil)
}
-
type accessTestFn func(ca *access.ChainAccess, bc *core.BlockChain, bhash common.Hash) access.ObjectAccess
func TestBlockAccessLes1(t *testing.T) { testAccess(t, 1, true, tfBlockAccess) }
func tfBlockAccess(ca *access.ChainAccess, bc *core.BlockChain, bhash common.Hash) access.ObjectAccess {
- return core.NewBlockAccess(ca.Db(), bhash)
+ return requests.NewBlockAccess(ca.Db(), bhash, core.GetHeader)
}
func TestReceiptsAccessLes1(t *testing.T) { testAccess(t, 1, true, tfReceiptsAccess) }
func tfReceiptsAccess(ca *access.ChainAccess, bc *core.BlockChain, bhash common.Hash) access.ObjectAccess {
- return core.NewReceiptsAccess(ca.Db(), bhash)
+ return requests.NewReceiptsAccess(ca.Db(), bhash, core.GetHeader, core.PutReceipts, core.PutBlockReceipts)
}
func TestTrieEntryAccessLes1(t *testing.T) { testAccess(t, 1, false, tfTrieEntryAccess) }
func tfTrieEntryAccess(ca *access.ChainAccess, bc *core.BlockChain, bhash common.Hash) access.ObjectAccess {
- return state.NewTrieEntryAccess(bc.GetHeader(bhash).Root, ca.Db(), testBankSecureTrieKey)
+ return requests.NewTrieEntryAccess(bc.GetHeader(bhash).Root, ca.Db(), testBankSecureTrieKey)
}
func TestNodeDataAccessLes1(t *testing.T) { testAccess(t, 1, true, tfNodeDataAccess) }
func tfNodeDataAccess(ca *access.ChainAccess, bc *core.BlockChain, bhash common.Hash) access.ObjectAccess {
- return state.NewNodeDataAccess(ca.Db(), bc.GetHeader(bhash).Root)
+ return requests.NewNodeDataAccess(ca.Db(), bc.GetHeader(bhash).Root)
}
func testAccess(t *testing.T, protocol int, shouldCache bool, fn accessTestFn) {
@@ -85,7 +84,7 @@ func testAccess(t *testing.T, protocol int, shouldCache bool, fn accessTestFn) {
test(5)
lca.UnregisterPeer(lpeer.id)
if shouldCache {
- // still expect all retrievals to pass, now data should be cached locally
+ // still expect all retrievals to pass, now data should be cached locally
test(5)
}
}
diff --git a/core/core_access.go b/les/requests/block_access.go
similarity index 77%
rename from core/core_access.go
rename to les/requests/block_access.go
index 588d580f0b..7158088bdb 100644
--- a/core/core_access.go
+++ b/les/requests/block_access.go
@@ -14,29 +14,42 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package core
+package requests
import (
"bytes"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
)
+var (
+ blockReceiptsPre = []byte("receipts-block-")
+ blockPrefix = []byte("block-")
+ bodySuffix = []byte("-body")
+)
+
// ODR request type for block bodies, see access.ObjectAccess interface
type BlockAccess struct {
db ethdb.Database
blockHash common.Hash
rlp []byte
+ getHeader getHeaderFn
}
-func NewBlockAccess(db ethdb.Database, blockHash common.Hash) *BlockAccess {
- return &BlockAccess{db: db, blockHash: blockHash}
+type getHeaderFn func(db ethdb.Database, hash common.Hash) *types.Header
+
+func NewBlockAccess(db ethdb.Database, blockHash common.Hash, getHeader getHeaderFn) *BlockAccess {
+ return &BlockAccess{db: db, blockHash: blockHash, getHeader: getHeader}
+}
+
+func (self *BlockAccess) GetRlp() []byte {
+ return self.rlp
}
func (self *BlockAccess) Request(peer *access.Peer) error {
@@ -56,7 +69,7 @@ func (self *BlockAccess) Valid(msg *access.Msg) bool {
return false
}
body := bodies[0]
- header := GetHeader(self.db, self.blockHash)
+ header := self.getHeader(self.db, self.blockHash)
if header == nil {
glog.V(access.LogLevel).Infof("ODR: header not found for block %08x", self.blockHash[:4])
return false
@@ -94,13 +107,23 @@ func (self *BlockAccess) DbPut() {
// ODR request type for block receipts by block hash, see access.ObjectAccess interface
type ReceiptsAccess struct {
- db ethdb.Database
- blockHash common.Hash
- receipts types.Receipts
+ db ethdb.Database
+ blockHash common.Hash
+ receipts types.Receipts
+ getHeader getHeaderFn
+ putReceipts putReceiptsFn
+ putBlockReceipts putBlockReceiptsFn
}
-func NewReceiptsAccess(db ethdb.Database, blockHash common.Hash) *ReceiptsAccess {
- return &ReceiptsAccess{db: db, blockHash: blockHash}
+type putReceiptsFn func(db ethdb.Database, receipts types.Receipts) error
+type putBlockReceiptsFn func(db ethdb.Database, hash common.Hash, receipts types.Receipts) error
+
+func NewReceiptsAccess(db ethdb.Database, blockHash common.Hash, getHeader getHeaderFn, putReceipts putReceiptsFn, putBlockReceipts putBlockReceiptsFn) *ReceiptsAccess {
+ return &ReceiptsAccess{db: db, blockHash: blockHash, getHeader: getHeader, putReceipts: putReceipts, putBlockReceipts: putBlockReceipts}
+}
+
+func (self *ReceiptsAccess) GetReceipts() types.Receipts {
+ return self.receipts
}
func (self *ReceiptsAccess) Request(peer *access.Peer) error {
@@ -120,7 +143,7 @@ func (self *ReceiptsAccess) Valid(msg *access.Msg) bool {
return false
}
hash := types.DeriveSha(receipts[0])
- header := GetHeader(self.db, self.blockHash)
+ header := self.getHeader(self.db, self.blockHash)
if header == nil {
glog.V(access.LogLevel).Infof("ODR: header not found for block %08x", self.blockHash[:4])
return false
@@ -152,6 +175,6 @@ func (self *ReceiptsAccess) DbGet() bool {
}
func (self *ReceiptsAccess) DbPut() {
- PutBlockReceipts(self.db, self.blockHash, self.receipts)
- PutReceipts(self.db, self.receipts)
+ self.putBlockReceipts(self.db, self.blockHash, self.receipts)
+ self.putReceipts(self.db, self.receipts)
}
diff --git a/core/state/state_access.go b/les/requests/trie_access.go
similarity index 98%
rename from core/state/state_access.go
rename to les/requests/trie_access.go
index a2989a97fe..cac0cf355e 100644
--- a/core/state/state_access.go
+++ b/les/requests/trie_access.go
@@ -15,16 +15,16 @@
// along with the go-ethereum library. If not, see .
// Package state provides a caching layer atop the Ethereum state trie.
-package state
+package requests
import (
"bytes"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/trie"
)
diff --git a/miner/worker.go b/miner/worker.go
index af1ad5b8c0..dacaa1d97a 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
diff --git a/rpc/api/debug.go b/rpc/api/debug.go
index e28dee70d0..53010afdac 100644
--- a/rpc/api/debug.go
+++ b/rpc/api/debug.go
@@ -22,7 +22,7 @@ import (
"time"
"github.com/ethereum/ethash"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth"
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index bc620d78a3..3ff98fd73b 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.go
@@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/natspec"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
diff --git a/rpc/comms/comms.go b/rpc/comms/comms.go
index 794810efa2..d44f960de2 100644
--- a/rpc/comms/comms.go
+++ b/rpc/comms/comms.go
@@ -24,7 +24,7 @@ import (
"strconv"
"time"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/codec"
diff --git a/rpc/comms/http.go b/rpc/comms/http.go
index 85c8edaafd..637b2bb910 100644
--- a/rpc/comms/http.go
+++ b/rpc/comms/http.go
@@ -29,7 +29,7 @@ import (
"io"
"io/ioutil"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/codec"
diff --git a/rpc/comms/inproc.go b/rpc/comms/inproc.go
index 4e4e9e9b84..af6462efb6 100644
--- a/rpc/comms/inproc.go
+++ b/rpc/comms/inproc.go
@@ -20,7 +20,7 @@ import (
"fmt"
"time"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
)
diff --git a/rpc/shared/types.go b/rpc/shared/types.go
index 94ea5530d7..52b20c132a 100644
--- a/rpc/shared/types.go
+++ b/rpc/shared/types.go
@@ -19,7 +19,7 @@ package shared
import (
"encoding/json"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
)
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index 70ac8024d8..9afdb59675 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -31,7 +31,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/tests/state_test_util.go b/tests/state_test_util.go
index 2499872ac7..771a2cc8cc 100644
--- a/tests/state_test_util.go
+++ b/tests/state_test_util.go
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/tests/util.go b/tests/util.go
index 3ba6a36112..2e6b9124a6 100644
--- a/tests/util.go
+++ b/tests/util.go
@@ -23,7 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go
index 858acfde8e..e3ae81563c 100644
--- a/tests/vm_test_util.go
+++ b/tests/vm_test_util.go
@@ -25,7 +25,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
diff --git a/trie/iterator.go b/trie/iterator.go
index 324cc655ce..fb32040db1 100644
--- a/trie/iterator.go
+++ b/trie/iterator.go
@@ -19,7 +19,7 @@ package trie
import (
"bytes"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
)
type Iterator struct {
diff --git a/trie/iterator_test.go b/trie/iterator_test.go
index ab057eb37b..1b18044350 100644
--- a/trie/iterator_test.go
+++ b/trie/iterator_test.go
@@ -19,7 +19,7 @@ package trie
import (
"testing"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
)
func TestIterator(t *testing.T) {
diff --git a/trie/proof.go b/trie/proof.go
index bfadceb5ab..70257971c9 100644
--- a/trie/proof.go
+++ b/trie/proof.go
@@ -6,7 +6,7 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/rlp"
)
diff --git a/trie/proof_test.go b/trie/proof_test.go
index 909936a7a0..e077985db7 100644
--- a/trie/proof_test.go
+++ b/trie/proof_test.go
@@ -8,7 +8,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/rlp"
)
diff --git a/trie/secure_trie.go b/trie/secure_trie.go
index 0623fab6bb..a5d75c0c95 100644
--- a/trie/secure_trie.go
+++ b/trie/secure_trie.go
@@ -20,7 +20,7 @@ import (
"hash"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/crypto/sha3"
)
diff --git a/trie/secure_trie_test.go b/trie/secure_trie_test.go
index f22566fcfa..2277a5498a 100644
--- a/trie/secure_trie_test.go
+++ b/trie/secure_trie_test.go
@@ -21,7 +21,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
)
diff --git a/trie/sync_test.go b/trie/sync_test.go
index fcabdf39d8..8258ade511 100644
--- a/trie/sync_test.go
+++ b/trie/sync_test.go
@@ -21,7 +21,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/ethdb"
)
diff --git a/trie/trie.go b/trie/trie.go
index b099b27b6b..438cfa6917 100644
--- a/trie/trie.go
+++ b/trie/trie.go
@@ -24,7 +24,7 @@ import (
"hash"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/logger"
diff --git a/trie/trie_test.go b/trie/trie_test.go
index 4c100a20b5..347307aeda 100644
--- a/trie/trie_test.go
+++ b/trie/trie_test.go
@@ -26,7 +26,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/ethdb"
)
diff --git a/xeth/types.go b/xeth/types.go
index 6207d423b1..e00975d991 100644
--- a/xeth/types.go
+++ b/xeth/types.go
@@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 3181ee6d62..a6477efeb3 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -31,7 +31,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/access"
+ "github.com/ethereum/go-ethereum/les/access"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"