Transaction queue: handle non-existant hash

This commit is contained in:
Victor Farazdagi 2016-08-05 23:42:11 +03:00
parent 5c0b128d5e
commit 231cd55c47
4 changed files with 34 additions and 16 deletions

3
.gitignore vendored
View File

@ -33,3 +33,6 @@ profile.cov
# vagrant
.vagrant
# tests
src/.ethereumtest/

View File

@ -20,6 +20,7 @@ import (
// TestAccountBindings makes sure we can create an account and subsequently
// unlock that account
func TestAccountBindings(t *testing.T) {
rpcport = 8546 // in order to avoid conflicts with running react-native app
// start geth node and wait for it to initialize
go createAndStartNode(".ethereumtest")
@ -99,6 +100,12 @@ func TestAccountBindings(t *testing.T) {
sentinel = 1
})
// try completing non-existing transaction
if err := completeTransaction("0x1234512345123451234512345123456123451234512345123451234512345123"); err == nil {
t.Errorf("Test failed: error expected and not recieved")
}
// send normal transaction
from, err := utils.MakeAddress(accountManager, address1)
if err != nil {
t.Errorf("Test failed: Could not retrieve account from address: %v", err)

View File

@ -15,9 +15,9 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/release"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/whisper"
"gopkg.in/urfave/cli.v1"
"github.com/ethereum/go-ethereum/rpc"
)
const (
@ -31,15 +31,16 @@ const (
)
var (
vString string // Combined textual representation of the version
rConfig release.Config // Structured version information and release oracle config
currentNode *node.Node // currently running geth node
c *cli.Context // the CLI context used to start the geth node
accountSync *[]node.Service // the object used to sync accounts between geth services
lightEthereum *les.LightEthereum // LES service
accountManager *accounts.Manager // the account manager attached to the currentNode
whisperService *whisper.Whisper // whisper service
datadir string // data directory for geth
vString string // Combined textual representation of the version
rConfig release.Config // Structured version information and release oracle config
currentNode *node.Node // currently running geth node
c *cli.Context // the CLI context used to start the geth node
accountSync *[]node.Service // the object used to sync accounts between geth services
lightEthereum *les.LightEthereum // LES service
accountManager *accounts.Manager // the account manager attached to the currentNode
whisperService *whisper.Whisper // whisper service
datadir string // data directory for geth
rpcport int = 8545 // RPC port (replaced in unit tests)
client rpc.Client
)
@ -63,7 +64,7 @@ func MakeNode(inputDir string) *node.Node {
set.Bool("testnet", true, "light test network")
set.Bool("rpc", true, "enable rpc")
set.String("rpcaddr", "localhost", "host for RPC")
set.String("rpcport", "8545", "rpc port")
set.Int("rpcport", rpcport, "rpc port")
set.String("rpccorsdomain", "*", "allow all domains")
set.String("verbosity", "3", "verbosity level")
set.String("rpcapi", "db,eth,net,web3,shh,personal,admin", "rpc api(s)")

View File

@ -9,11 +9,18 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc"
"errors"
)
const defaultTxQueueCap = int(5)
const defaultEvictingTxQueueCap = int(20)
const defaultEvictingTxQueueEvictionStep = int(5) // how many item to evict in a single run
const (
defaultTxQueueCap = int(5) // how many items can be passed to sendTransaction() w/o blocking
defaultEvictingTxQueueCap = int(20) // how many items can be queued
defaultEvictingTxQueueEvictionStep = int(5) // how many item to evict in a single run
)
var (
ErrQueuedTxHashNotFound = errors.New("Transaction hash not found")
)
// StatusBackend implements les.StatusBackend with direct calls to Ethereum
// internals to support calls from status-go bindings (to internal packages e.g. ethapi)
@ -113,7 +120,7 @@ func (b *StatusBackend) GetTransactionQueue() (chan QueuedTx, error) {
func (b *StatusBackend) transactionQueueForwardingLoop() {
txQueue, err := b.txapi.GetTransactionQueue()
if err != nil {
glog.V(logger.Error).Infof("Cannot read from transaction queue")
glog.V(logger.Error).Infof("cannot read from transaction queue")
return
}
@ -158,5 +165,5 @@ func (q *evictingTxQueue) getQueuedTransaction(hash QueuedTxHash) (*QueuedTx, er
return tx, nil
}
return nil, nil
return nil, ErrQueuedTxHashNotFound
}