Skip to content
Snippets Groups Projects
Unverified Commit eb2dc0b6 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

fix merge conflict; merge in silasdavis/activate_servers

parents ed0a6680 8d5d21e3
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ package core ...@@ -2,6 +2,7 @@ package core
import ( import (
"fmt" "fmt"
acm "github.com/eris-ltd/eris-db/account" acm "github.com/eris-ltd/eris-db/account"
ctypes "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" ctypes "github.com/eris-ltd/eris-db/rpc/tendermint/core/types"
. "github.com/tendermint/go-common" . "github.com/tendermint/go-common"
...@@ -13,7 +14,7 @@ func GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) { ...@@ -13,7 +14,7 @@ func GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) {
// If the account is not known, returns nil, nil. // If the account is not known, returns nil, nil.
func GetAccount(address []byte) (*ctypes.ResultGetAccount, error) { func GetAccount(address []byte) (*ctypes.ResultGetAccount, error) {
cache := erisdbApp.GetCheckCache() cache := erisMint.GetCheckCache()
// cache := mempoolReactor.Mempool.GetCache() // cache := mempoolReactor.Mempool.GetCache()
account := cache.GetAccount(address) account := cache.GetAccount(address)
if account == nil { if account == nil {
...@@ -24,7 +25,7 @@ func GetAccount(address []byte) (*ctypes.ResultGetAccount, error) { ...@@ -24,7 +25,7 @@ func GetAccount(address []byte) (*ctypes.ResultGetAccount, error) {
} }
func GetStorage(address, key []byte) (*ctypes.ResultGetStorage, error) { func GetStorage(address, key []byte) (*ctypes.ResultGetStorage, error) {
state := erisdbApp.GetState() state := erisMint.GetState()
// state := consensusState.GetState() // state := consensusState.GetState()
account := state.GetAccount(address) account := state.GetAccount(address)
if account == nil { if account == nil {
...@@ -43,7 +44,7 @@ func GetStorage(address, key []byte) (*ctypes.ResultGetStorage, error) { ...@@ -43,7 +44,7 @@ func GetStorage(address, key []byte) (*ctypes.ResultGetStorage, error) {
func ListAccounts() (*ctypes.ResultListAccounts, error) { func ListAccounts() (*ctypes.ResultListAccounts, error) {
var blockHeight int var blockHeight int
var accounts []*acm.Account var accounts []*acm.Account
state := erisdbApp.GetState() state := erisMint.GetState()
blockHeight = state.LastBlockHeight blockHeight = state.LastBlockHeight
state.GetAccounts().Iterate(func(key []byte, value []byte) bool { state.GetAccounts().Iterate(func(key []byte, value []byte) bool {
accounts = append(accounts, acm.DecodeAccount(value)) accounts = append(accounts, acm.DecodeAccount(value))
...@@ -53,7 +54,7 @@ func ListAccounts() (*ctypes.ResultListAccounts, error) { ...@@ -53,7 +54,7 @@ func ListAccounts() (*ctypes.ResultListAccounts, error) {
} }
func DumpStorage(address []byte) (*ctypes.ResultDumpStorage, error) { func DumpStorage(address []byte) (*ctypes.ResultDumpStorage, error) {
state := erisdbApp.GetState() state := erisMint.GetState()
account := state.GetAccount(address) account := state.GetAccount(address)
if account == nil { if account == nil {
return nil, fmt.Errorf("UnknownAddress: %X", address) return nil, fmt.Errorf("UnknownAddress: %X", address)
......
...@@ -2,6 +2,7 @@ package core ...@@ -2,6 +2,7 @@ package core
import ( import (
"fmt" "fmt"
ctypes "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" ctypes "github.com/eris-ltd/eris-db/rpc/tendermint/core/types"
txs "github.com/eris-ltd/eris-db/txs" txs "github.com/eris-ltd/eris-db/txs"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
...@@ -21,7 +22,6 @@ func BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { ...@@ -21,7 +22,6 @@ func BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
// Note: tx must be signed // Note: tx must be signed
func BroadcastTxSync(tx txs.Tx) (*ctypes.ResultBroadcastTx, error) { func BroadcastTxSync(tx txs.Tx) (*ctypes.ResultBroadcastTx, error) {
fmt.Println("BROADCAST!", tx)
resCh := make(chan *tmsp.Response, 1) resCh := make(chan *tmsp.Response, 1)
err := mempoolReactor.BroadcastTx(txs.EncodeTx(tx), func(res *tmsp.Response) { err := mempoolReactor.BroadcastTx(txs.EncodeTx(tx), func(res *tmsp.Response) {
resCh <- res resCh <- res
...@@ -30,9 +30,37 @@ func BroadcastTxSync(tx txs.Tx) (*ctypes.ResultBroadcastTx, error) { ...@@ -30,9 +30,37 @@ func BroadcastTxSync(tx txs.Tx) (*ctypes.ResultBroadcastTx, error) {
return nil, fmt.Errorf("Error broadcasting transaction: %v", err) return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
} }
res := <-resCh res := <-resCh
return &ctypes.ResultBroadcastTx{ switch r:= res.Value.(type) {
Code: res.Code, case *tmsp.Response_AppendTx:
Data: res.Data, return &ctypes.ResultBroadcastTx{
Log: res.Log, Code: r.AppendTx.Code,
}, nil Data: r.AppendTx.Data,
Log: r.AppendTx.Log,
}, nil
case *tmsp.Response_CheckTx:
return &ctypes.ResultBroadcastTx{
Code: r.CheckTx.Code,
Data: r.CheckTx.Data,
Log: r.CheckTx.Log,
}, nil
case *tmsp.Response_Commit:
return &ctypes.ResultBroadcastTx{
Code: r.Commit.Code,
Data: r.Commit.Data,
Log: r.Commit.Log,
}, nil
case *tmsp.Response_Query:
return &ctypes.ResultBroadcastTx{
Code: r.Query.Code,
Data: r.Query.Data,
Log: r.Query.Log,
}, nil
default:
return &ctypes.ResultBroadcastTx{
Code: tmsp.CodeType_OK,
Data: []byte{},
Log: "",
}, nil
}
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
) )
func GetName(name string) (*ctypes.ResultGetName, error) { func GetName(name string) (*ctypes.ResultGetName, error) {
st := erisdbApp.GetState() st := erisMint.GetState()
entry := st.GetNameRegEntry(name) entry := st.GetNameRegEntry(name)
if entry == nil { if entry == nil {
return nil, fmt.Errorf("Name %s not found", name) return nil, fmt.Errorf("Name %s not found", name)
...@@ -20,7 +20,7 @@ func GetName(name string) (*ctypes.ResultGetName, error) { ...@@ -20,7 +20,7 @@ func GetName(name string) (*ctypes.ResultGetName, error) {
func ListNames() (*ctypes.ResultListNames, error) { func ListNames() (*ctypes.ResultListNames, error) {
var blockHeight int var blockHeight int
var names []*txs.NameRegEntry var names []*txs.NameRegEntry
state := erisdbApp.GetState() state := erisMint.GetState()
blockHeight = state.LastBlockHeight blockHeight = state.LastBlockHeight
state.GetNames().Iterate(func(key []byte, value []byte) bool { state.GetNames().Iterate(func(key []byte, value []byte) bool {
names = append(names, sm.DecodeNameRegEntry(value)) names = append(names, sm.DecodeNameRegEntry(value))
......
package core package core
import ( import (
erismint "github.com/eris-ltd/eris-db/manager/eris-mint"
stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types"
"github.com/eris-ltd/eris-db/tmsp"
bc "github.com/tendermint/tendermint/blockchain" bc "github.com/tendermint/tendermint/blockchain"
"github.com/tendermint/tendermint/consensus" "github.com/tendermint/tendermint/consensus"
...@@ -20,7 +20,7 @@ var mempoolReactor *mempl.MempoolReactor ...@@ -20,7 +20,7 @@ var mempoolReactor *mempl.MempoolReactor
var p2pSwitch *p2p.Switch var p2pSwitch *p2p.Switch
var privValidator *tmtypes.PrivValidator var privValidator *tmtypes.PrivValidator
var genDoc *stypes.GenesisDoc // cache the genesis structure var genDoc *stypes.GenesisDoc // cache the genesis structure
var erisdbApp *tmsp.ErisDBApp var erisMint *erismint.ErisMint
var config cfg.Config = nil var config cfg.Config = nil
...@@ -28,8 +28,8 @@ func SetConfig(c cfg.Config) { ...@@ -28,8 +28,8 @@ func SetConfig(c cfg.Config) {
config = c config = c
} }
func SetErisDBApp(edbApp *tmsp.ErisDBApp) { func SetErisDBApp(edbApp *erismint.ErisMint) {
erisdbApp = edbApp erisMint = edbApp
} }
func SetBlockStore(bs *bc.BlockStore) { func SetBlockStore(bs *bc.BlockStore) {
......
...@@ -28,7 +28,7 @@ func toVMAccount(acc *acm.Account) *vm.Account { ...@@ -28,7 +28,7 @@ func toVMAccount(acc *acm.Account) *vm.Account {
// Run a contract's code on an isolated and unpersisted state // Run a contract's code on an isolated and unpersisted state
// Cannot be used to create new contracts // Cannot be used to create new contracts
func Call(fromAddress, toAddress, data []byte) (*ctypes.ResultCall, error) { func Call(fromAddress, toAddress, data []byte) (*ctypes.ResultCall, error) {
st := erisdbApp.GetState() st := erisMint.GetState()
cache := state.NewBlockCache(st) cache := state.NewBlockCache(st)
outAcc := cache.GetAccount(toAddress) outAcc := cache.GetAccount(toAddress)
if outAcc == nil { if outAcc == nil {
...@@ -57,8 +57,8 @@ func Call(fromAddress, toAddress, data []byte) (*ctypes.ResultCall, error) { ...@@ -57,8 +57,8 @@ func Call(fromAddress, toAddress, data []byte) (*ctypes.ResultCall, error) {
// Cannot be used to create new contracts // Cannot be used to create new contracts
func CallCode(fromAddress, code, data []byte) (*ctypes.ResultCall, error) { func CallCode(fromAddress, code, data []byte) (*ctypes.ResultCall, error) {
st := erisdbApp.GetState() st := erisMint.GetState()
cache := erisdbApp.GetCheckCache() cache := erisMint.GetCheckCache()
callee := &vm.Account{Address: LeftPadWord256(fromAddress)} callee := &vm.Account{Address: LeftPadWord256(fromAddress)}
caller := &vm.Account{Address: LeftPadWord256(fromAddress)} caller := &vm.Account{Address: LeftPadWord256(fromAddress)}
txCache := state.NewTxCache(cache) txCache := state.NewTxCache(cache)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment