mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Merge pull request #48 from ShyftNetwork/update/accountBalances
Update/account balances
This commit is contained in:
commit
f345b88d07
23 changed files with 853 additions and 900 deletions
|
|
@ -29,7 +29,6 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/common/mclock"
|
||||
"github.com/ShyftNetwork/go-empyrean/consensus"
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import (
|
|||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/big"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/types"
|
||||
|
|
@ -283,14 +283,7 @@ func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64,
|
|||
// its added positional metadata.
|
||||
func GetTransaction(db DatabaseReader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
|
||||
// Retrieve the lookup metadata and resolve the transaction from the body
|
||||
//fmt.Println("INSIDE GET TRANSACTION ++++++++")
|
||||
//fmt.Println("The hash and db reader are")
|
||||
//fmt.Println(hash)
|
||||
//fmt.Println(db)
|
||||
blockHash, blockNumber, txIndex := GetTxLookupEntry(db, hash)
|
||||
//fmt.Println(blockHash)
|
||||
//fmt.Println(blockNumber)
|
||||
|
||||
if blockHash != (common.Hash{}) {
|
||||
body := GetBody(db, blockHash, blockNumber)
|
||||
if body == nil || len(body.Transactions) <= int(txIndex) {
|
||||
|
|
|
|||
25
core/db.go
25
core/db.go
|
|
@ -62,3 +62,28 @@ func DBConnection() (*sql.DB, error) {
|
|||
}
|
||||
return blockExplorerDb, nil
|
||||
}
|
||||
|
||||
func ClearTables() {
|
||||
sqldb, err := DBConnection()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlStatementTx:= `DELETE FROM txs`
|
||||
_, err = sqldb.Exec(sqlStatementTx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlStatementAcc:= `DELETE FROM accounts`
|
||||
_, err = sqldb.Exec(sqlStatementAcc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlStatement := `DELETE FROM blocks`
|
||||
_, err = sqldb.Exec(sqlStatement)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
140
core/genesis.go
140
core/genesis.go
|
|
@ -18,26 +18,27 @@ package core
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/common/hexutil"
|
||||
"github.com/ShyftNetwork/go-empyrean/common/math"
|
||||
stypes "github.com/ShyftNetwork/go-empyrean/core/sTypes"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/state"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/types"
|
||||
"github.com/ShyftNetwork/go-empyrean/ethdb"
|
||||
"github.com/ShyftNetwork/go-empyrean/log"
|
||||
"github.com/ShyftNetwork/go-empyrean/params"
|
||||
"github.com/ShyftNetwork/go-empyrean/rlp"
|
||||
"database/sql"
|
||||
"strconv"
|
||||
"time"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
//go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go
|
||||
|
|
@ -143,85 +144,90 @@ func (e *GenesisMismatchError) Error() string {
|
|||
//WriteShyftGen writes the genesis block to Shyft db
|
||||
//@NOTE:SHYFT
|
||||
func WriteShyftGen(gen *Genesis, block *types.Block) {
|
||||
|
||||
sqldb, _ := DBConnection()
|
||||
|
||||
for k := range gen.Alloc {
|
||||
addr := k.String()
|
||||
var response string
|
||||
sqlExistsStatement := `SELECT balance from accounts WHERE addr = ($1)`
|
||||
err := sqldb.QueryRow(sqlExistsStatement, addr).Scan(&response)
|
||||
for k, v := range gen.Alloc {
|
||||
_, _, err := AccountExists(sqldb, k.String())
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
for k, v := range gen.Alloc {
|
||||
number := block.Header().Number.String()
|
||||
gasUsed := block.Header().GasUsed
|
||||
gasLimit := block.Header().GasLimit
|
||||
gasPrice := 0
|
||||
txFee := 0
|
||||
txStatus := ""
|
||||
isContract := false
|
||||
data:= ""
|
||||
addr := k.String()
|
||||
var toAddr *common.Address
|
||||
var data []byte
|
||||
var cost, gasPrice uint64
|
||||
//Initializing proper types for tx struct
|
||||
toAddr = &k
|
||||
cost = 0
|
||||
gasPrice = 0
|
||||
//Appending GENESIS to address stored as txHash and From Addr
|
||||
Genesis := []string{"GENESIS_", k.String()}
|
||||
GENESIS := "GENESIS"
|
||||
txHash := strings.Join(Genesis, k.String())
|
||||
//Create the accountNonce, set to 1 (1 incoming tx), format type
|
||||
accountNonce := v.Nonce + 1
|
||||
accountNoncee := strconv.FormatUint(accountNonce, 10)
|
||||
|
||||
i, err := strconv.ParseInt(block.Time().String(), 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
age := time.Unix(i, 0)
|
||||
Genesis := []string{"GENESIS_", addr}
|
||||
GENESIS := "GENESIS"
|
||||
txHash := strings.Join(Genesis, addr)
|
||||
|
||||
sqlStatement := `INSERT INTO accounts(addr, balance, accountnonce) VALUES(($1), ($2), ($3)) RETURNING addr`
|
||||
insertErr := sqldb.QueryRow(sqlStatement, addr, v.Balance.String(), accountNonce).Scan(&addr)
|
||||
if insertErr != nil {
|
||||
panic(insertErr)
|
||||
txData := stypes.ShyftTxEntryPretty{
|
||||
TxHash: txHash,
|
||||
From: GENESIS,
|
||||
To: toAddr,
|
||||
BlockHash: block.Header().Hash().Hex(),
|
||||
BlockNumber: block.Header().Number.String(),
|
||||
Amount: v.Balance.String(),
|
||||
Cost: cost,
|
||||
GasPrice: gasPrice,
|
||||
GasLimit: block.GasLimit(),
|
||||
Gas: block.GasUsed(),
|
||||
Nonce: accountNonce,
|
||||
Age: age,
|
||||
Data: data,
|
||||
Status: "SUCCESS",
|
||||
IsContract: false,
|
||||
}
|
||||
//Create account and store tx
|
||||
CreateAccount(sqldb, k.String(), v.Balance.String(), accountNoncee)
|
||||
InsertTx(sqldb, txData)
|
||||
|
||||
var retNonce string
|
||||
sqlGenTxStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount,gasPrice, gas, gasLimit,txFee,nonce,txstatus, iscontract,age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce`
|
||||
insertError := sqldb.QueryRow(sqlGenTxStatement, txHash, GENESIS, addr, block.Header().Hash().Hex(), number, v.Balance.String(), gasPrice, gasUsed, gasLimit, txFee,accountNonce,txStatus, isContract, age, data).Scan(&retNonce)
|
||||
if insertError != nil {
|
||||
panic(insertError)
|
||||
}
|
||||
}
|
||||
default:
|
||||
log.Info("Found Genesis Block")
|
||||
}}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//WriteShyftBlockZero writes block 0 to postgres db
|
||||
func WriteShyftBlockZero(block *types.Block, gen *Genesis) error {
|
||||
|
||||
sqldb, _ := DBConnection()
|
||||
|
||||
coinbase := block.Header().Coinbase.String()
|
||||
number := block.Header().Number.String()
|
||||
gasUsed := block.Header().GasUsed
|
||||
gasLimit := block.Header().GasLimit
|
||||
uncleCount := len(block.Uncles())
|
||||
parentHash := block.ParentHash().String()
|
||||
uncleHash := block.UncleHash().String()
|
||||
blockDifficulty := block.Difficulty().String()
|
||||
blockSize := block.Size().String()
|
||||
blockNonce := block.Nonce()
|
||||
genesisTxCount := len(gen.Alloc)
|
||||
|
||||
i, err := strconv.ParseInt(block.Time().String(), 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
i, error := strconv.ParseInt(block.Time().String(), 10, 64)
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
age := time.Unix(i, 0)
|
||||
|
||||
var response string
|
||||
sqlExistsStatement := `SELECT hash from blocks WHERE hash= ($1)`
|
||||
err = sqldb.QueryRow(sqlExistsStatement, block.Header().Hash().Hex()).Scan(&response)
|
||||
blockData := stypes.SBlock{
|
||||
Hash: block.Header().Hash().Hex(),
|
||||
Coinbase: block.Header().Coinbase.String(),
|
||||
Number: block.Header().Number.String(),
|
||||
GasUsed: block.Header().GasUsed,
|
||||
GasLimit: block.Header().GasLimit,
|
||||
TxCount: len(gen.Alloc),
|
||||
UncleCount: len(block.Uncles()),
|
||||
Age: age,
|
||||
ParentHash: block.ParentHash().String(),
|
||||
UncleHash: block.UncleHash().String(),
|
||||
Difficulty: block.Difficulty().String(),
|
||||
Size: block.Size().String(),
|
||||
Nonce: block.Nonce(),
|
||||
Rewards: "0",
|
||||
}
|
||||
|
||||
err := BlockExists(sqldb, blockData.Hash)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
sqlStatement := `INSERT INTO blocks(hash, coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, difficulty, size, nonce) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12),($13)) RETURNING number`
|
||||
qerr := sqldb.QueryRow(sqlStatement, block.Header().Hash().Hex(), coinbase, number, gasUsed, gasLimit, genesisTxCount, uncleCount, age, parentHash, uncleHash, blockDifficulty, blockSize, blockNonce).Scan(&number)
|
||||
if qerr != nil {
|
||||
panic(qerr)
|
||||
}
|
||||
InsertBlock(sqldb, blockData)
|
||||
case err != nil:
|
||||
panic(err)
|
||||
default:
|
||||
|
|
@ -229,6 +235,7 @@ func WriteShyftBlockZero(block *types.Block, gen *Genesis) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetupGenesisBlock writes or updates the genesis block in db.
|
||||
// The block that will be used is:
|
||||
//
|
||||
|
|
@ -256,11 +263,20 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
|
|||
log.Info("Writing custom genesis block")
|
||||
}
|
||||
block, err := genesis.Commit(db)
|
||||
//@NOTE:SHYFT SWITCH CASE ENSURES SHYFT GENESIS FUNCTIONS ARE ONLY CALLED ONCE
|
||||
sqldb, _ := DBConnection()
|
||||
serror := BlockExists(sqldb, block.Hash().String())
|
||||
switch {
|
||||
case serror == sql.ErrNoRows:
|
||||
//@NOTE:SHYFT WRITE TO BLOCK ZERO DB
|
||||
WriteShyftBlockZero(block, genesis)
|
||||
//@NOTE:SHYFT WRITE TO DB
|
||||
WriteShyftGen(genesis, block)
|
||||
|
||||
case serror != nil:
|
||||
panic(serror)
|
||||
default:
|
||||
log.Info("Genesis Block Written")
|
||||
}
|
||||
return genesis.Config, block.Hash(), err
|
||||
}
|
||||
|
||||
|
|
@ -315,6 +331,7 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
|
|||
return params.AllEthashProtocolChanges
|
||||
}
|
||||
}
|
||||
|
||||
// ToBlock creates the genesis block and writes state of a genesis specification
|
||||
// to the given database (or discards it if nil).
|
||||
func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
|
||||
|
|
@ -439,6 +456,7 @@ func DefaultRinkebyGenesisBlock() *Genesis {
|
|||
Alloc: decodePrealloc(rinkebyAllocData),
|
||||
}
|
||||
}
|
||||
|
||||
// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must
|
||||
// be seeded with the
|
||||
func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {
|
||||
|
|
|
|||
92
core/sTypes/stypes.go
Normal file
92
core/sTypes/stypes.go
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
package stypes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
)
|
||||
|
||||
//SBlock type
|
||||
type SBlock struct {
|
||||
Hash string
|
||||
Coinbase string
|
||||
AgeGet string
|
||||
Age time.Time
|
||||
ParentHash string
|
||||
UncleHash string
|
||||
Difficulty string
|
||||
Size string
|
||||
Rewards string
|
||||
Number string
|
||||
GasUsed uint64
|
||||
GasLimit uint64
|
||||
Nonce uint64
|
||||
TxCount int
|
||||
UncleCount int
|
||||
Blocks []SBlock
|
||||
}
|
||||
|
||||
type InteralWrite struct {
|
||||
Hash string
|
||||
Type string
|
||||
From string
|
||||
To string
|
||||
Value string
|
||||
Gas uint64
|
||||
GasUsed uint64
|
||||
Input string
|
||||
Output string
|
||||
Time string
|
||||
}
|
||||
|
||||
//blockRes struct
|
||||
type BlockRes struct {
|
||||
hash string
|
||||
coinbase string
|
||||
number string
|
||||
Blocks []SBlock
|
||||
}
|
||||
|
||||
type SAccounts struct {
|
||||
Addr string
|
||||
Balance string
|
||||
AccountNonce string
|
||||
}
|
||||
|
||||
type AccountRes struct {
|
||||
addr string
|
||||
balance string
|
||||
AllAccounts []SAccounts
|
||||
}
|
||||
|
||||
type TxRes struct {
|
||||
TxEntry []ShyftTxEntryPretty
|
||||
}
|
||||
|
||||
type ShyftTxEntryPretty struct {
|
||||
TxHash string
|
||||
To *common.Address
|
||||
ToGet string
|
||||
From string
|
||||
BlockHash string
|
||||
BlockNumber string
|
||||
Amount string
|
||||
GasPrice uint64
|
||||
Gas uint64
|
||||
GasLimit uint64
|
||||
Cost uint64
|
||||
Nonce uint64
|
||||
Status string
|
||||
IsContract bool
|
||||
Age time.Time
|
||||
Data []byte
|
||||
}
|
||||
|
||||
type SendAndReceive struct {
|
||||
To string
|
||||
From string
|
||||
Amount string
|
||||
Address string
|
||||
Balance string
|
||||
AccountNonce uint64 `json:",string"`
|
||||
}
|
||||
|
|
@ -1,106 +1,47 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
"strconv"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
_ "github.com/lib/pq"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/types"
|
||||
Rewards "github.com/ShyftNetwork/go-empyrean/consensus/ethash"
|
||||
stypes "github.com/ShyftNetwork/go-empyrean/core/sTypes"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/types"
|
||||
"github.com/ShyftNetwork/go-empyrean/shyfttracerinterface"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
//IShyftTracer Used to initialize ShyftTracer
|
||||
var IShyftTracer shyfttracerinterface.IShyftTracer
|
||||
|
||||
//SetIShyftTracer sets tracer type
|
||||
func SetIShyftTracer(st shyfttracerinterface.IShyftTracer) {
|
||||
IShyftTracer = st
|
||||
}
|
||||
|
||||
//SBlock type
|
||||
type SBlock struct {
|
||||
Hash string
|
||||
Coinbase string
|
||||
AgeGet string
|
||||
Age time.Time
|
||||
ParentHash string
|
||||
UncleHash string
|
||||
Difficulty string
|
||||
Size string
|
||||
Rewards string
|
||||
Number string
|
||||
GasUsed uint64
|
||||
GasLimit uint64
|
||||
Nonce uint64
|
||||
TxCount int
|
||||
UncleCount int
|
||||
Blocks []SBlock
|
||||
}
|
||||
|
||||
//blockRes struct
|
||||
type blockRes struct {
|
||||
hash string
|
||||
coinbase string
|
||||
number string
|
||||
Blocks []SBlock
|
||||
}
|
||||
|
||||
type SAccounts struct {
|
||||
Addr string
|
||||
Balance string
|
||||
AccountNonce string
|
||||
}
|
||||
|
||||
type accountRes struct {
|
||||
addr string
|
||||
balance string
|
||||
AllAccounts []SAccounts
|
||||
}
|
||||
|
||||
type txRes struct {
|
||||
TxEntry []ShyftTxEntryPretty
|
||||
}
|
||||
|
||||
type ShyftTxEntryPretty struct {
|
||||
TxHash string
|
||||
To *common.Address
|
||||
ToGet string
|
||||
From string
|
||||
BlockHash string
|
||||
BlockNumber string
|
||||
Amount string
|
||||
GasPrice uint64
|
||||
Gas uint64
|
||||
GasLimit uint64
|
||||
Cost uint64
|
||||
Nonce uint64
|
||||
Status string
|
||||
IsContract bool
|
||||
Age time.Time
|
||||
Data []byte
|
||||
}
|
||||
|
||||
type SendAndReceive struct {
|
||||
To string
|
||||
From string
|
||||
Amount string
|
||||
Address string
|
||||
Balance string
|
||||
AccountNonce uint64 `json:",string"`
|
||||
}
|
||||
|
||||
//WriteBlock writes to block info to sql db
|
||||
//SWriteBlock writes to block info to sql db
|
||||
func SWriteBlock(block *types.Block, receipts []*types.Receipt) error {
|
||||
sqldb, err := DBConnection()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//Get miner rewards
|
||||
rewards := swriteMinerRewards(sqldb, block)
|
||||
//Format block time to be stored
|
||||
i, err := strconv.ParseInt(block.Time().String(), 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
age := time.Unix(i, 0)
|
||||
|
||||
blockData := SBlock{
|
||||
blockData := stypes.SBlock{
|
||||
Hash: block.Header().Hash().Hex(),
|
||||
Coinbase: block.Header().Coinbase.String(),
|
||||
Number: block.Header().Number.String(),
|
||||
|
|
@ -114,30 +55,15 @@ func SWriteBlock(block *types.Block, receipts []*types.Receipt) error {
|
|||
Size: block.Size().String(),
|
||||
Nonce: block.Nonce(),
|
||||
Rewards: rewards,
|
||||
}
|
||||
|
||||
i, err := strconv.ParseInt(block.Time().String(), 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
age := time.Unix(i, 0)
|
||||
|
||||
blockAge := SBlock {
|
||||
Age: age,
|
||||
}
|
||||
|
||||
//Inserts block data into DB
|
||||
InsertBlock(sqldb, blockData, blockAge)
|
||||
InsertBlock(sqldb, blockData)
|
||||
|
||||
if block.Transactions().Len() > 0 {
|
||||
for _, tx := range block.Transactions() {
|
||||
swriteTransactions(sqldb, tx, block.Header().Hash(), blockData.Number, receipts, age, blockData.GasLimit)
|
||||
if block.Transactions()[0].To() != nil {
|
||||
swriteFromBalance(sqldb, tx)
|
||||
}
|
||||
if block.Transactions()[0].To() == nil {
|
||||
swriteContractBalance(sqldb, tx)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -147,24 +73,9 @@ func SWriteBlock(block *types.Block, receipts []*types.Receipt) error {
|
|||
func swriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error {
|
||||
var isContract bool
|
||||
var statusFromReciept string
|
||||
var toAddr *common.Address
|
||||
var contractAddressFromReciept common.Address
|
||||
|
||||
txData := ShyftTxEntryPretty{
|
||||
TxHash: tx.Hash().Hex(),
|
||||
From: tx.From().Hex(),
|
||||
To: tx.To(),
|
||||
BlockHash: blockHash.Hex(),
|
||||
BlockNumber: blockNumber,
|
||||
Amount: tx.Value().String(),
|
||||
Cost: tx.Cost().Uint64(),
|
||||
GasPrice: tx.GasPrice().Uint64(),
|
||||
GasLimit: gasLimit,
|
||||
Gas: tx.Gas(),
|
||||
Nonce: tx.Nonce(),
|
||||
Age: age,
|
||||
Data: tx.Data(),
|
||||
}
|
||||
|
||||
if tx.To() == nil {
|
||||
for _, receipt := range receipts {
|
||||
statusReciept := (*types.ReceiptForStorage)(receipt).Status
|
||||
|
|
@ -177,13 +88,7 @@ func swriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
|
|||
}
|
||||
}
|
||||
isContract = true
|
||||
contractData := ShyftTxEntryPretty{
|
||||
Status: statusFromReciept,
|
||||
IsContract: isContract,
|
||||
To: &contractAddressFromReciept,
|
||||
}
|
||||
//Insert Tx into DB
|
||||
InsertTx(sqldb, txData, contractData)
|
||||
toAddr = &contractAddressFromReciept
|
||||
} else {
|
||||
isContract = false
|
||||
for _, receipt := range receipts {
|
||||
|
|
@ -195,34 +100,67 @@ func swriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
|
|||
statusFromReciept = "SUCCESS"
|
||||
}
|
||||
}
|
||||
data := ShyftTxEntryPretty{
|
||||
toAddr = tx.To()
|
||||
}
|
||||
|
||||
txData := stypes.ShyftTxEntryPretty{
|
||||
TxHash: tx.Hash().Hex(),
|
||||
From: tx.From().Hex(),
|
||||
To: toAddr,
|
||||
BlockHash: blockHash.Hex(),
|
||||
BlockNumber: blockNumber,
|
||||
Amount: tx.Value().String(),
|
||||
Cost: tx.Cost().Uint64(),
|
||||
GasPrice: tx.GasPrice().Uint64(),
|
||||
GasLimit: gasLimit,
|
||||
Gas: tx.Gas(),
|
||||
Nonce: tx.Nonce(),
|
||||
Age: age,
|
||||
Data: tx.Data(),
|
||||
Status: statusFromReciept,
|
||||
IsContract: isContract,
|
||||
To: tx.To(),
|
||||
}
|
||||
//Insert Tx into DB
|
||||
InsertTx(sqldb, txData, data)
|
||||
}
|
||||
//Inserts Tx into DB
|
||||
InsertTx(sqldb, txData)
|
||||
//Runs necessary functions for tracing internal transactions through tracers.go
|
||||
IShyftTracer.GetTracerToRun(tx.Hash())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func swriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData := SendAndReceive{
|
||||
From: tx.From().Hex(),
|
||||
Amount: tx.Value().String(),
|
||||
AccountNonce: tx.Nonce(),
|
||||
//SWriteInternalTxBalances Writes internal txs and updates balances
|
||||
func SWriteInternalTxBalances(sqldb *sql.DB, toAddr string, fromAddr string, amount string) error {
|
||||
sendAndReceiveData := stypes.SendAndReceive{
|
||||
To: toAddr,
|
||||
From: fromAddr,
|
||||
Amount: amount,
|
||||
}
|
||||
|
||||
fromAddressBalance, fromAccountNonce, err := AccountExists(sqldb, sendAndReceiveData.From)
|
||||
|
||||
_, _, err := AccountExists(sqldb, sendAndReceiveData.To)
|
||||
value := new(big.Int)
|
||||
value, _ = value.SetString(amount, 10)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
accountNonce := strconv.FormatUint(tx.Nonce(), 10)
|
||||
CreateAccount(sqldb, sendAndReceiveData.From, sendAndReceiveData.Amount, accountNonce)
|
||||
accountNonce := "1"
|
||||
CreateAccount(sqldb, sendAndReceiveData.To, sendAndReceiveData.Amount, accountNonce)
|
||||
adjustBalanceFromAddr(sqldb, sendAndReceiveData, value)
|
||||
case err != nil:
|
||||
log.Fatal(err)
|
||||
default:
|
||||
balanceHelper(sqldb, sendAndReceiveData, amount)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func adjustBalanceFromAddr(sqldb *sql.DB, s stypes.SendAndReceive, value *big.Int) {
|
||||
fromAddressBalance, fromAccountNonce, err := AccountExists(sqldb, s.From)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
CreateAccount(sqldb, s.From, "0", "1")
|
||||
fmt.Println("New From account created")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
var newBalanceSender, newAccountNonceSender big.Int
|
||||
var nonceIncrement = big.NewInt(1)
|
||||
|
||||
|
|
@ -232,32 +170,15 @@ func swriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
|||
fromNonce := new(big.Int)
|
||||
fromNonce, _ = fromNonce.SetString(fromAccountNonce, 10)
|
||||
|
||||
newBalanceSender.Sub(fromBalance, tx.Value())
|
||||
newBalanceSender.Sub(fromBalance, value)
|
||||
newAccountNonceSender.Add(fromNonce, nonceIncrement)
|
||||
|
||||
UpdateAccount(sqldb, sendAndReceiveData.From, newBalanceSender.String(), newAccountNonceSender.String())
|
||||
}
|
||||
return nil
|
||||
UpdateAccount(sqldb, s.From, newBalanceSender.String(), newAccountNonceSender.String())
|
||||
}
|
||||
|
||||
//writeFromBalance writes senders balance to accounts db
|
||||
func swriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData := SendAndReceive{
|
||||
To: tx.To().Hex(),
|
||||
From: tx.From().Hex(),
|
||||
Amount: tx.Value().String(),
|
||||
}
|
||||
|
||||
toAddressBalance, toAccountNonce, err := AccountExists(sqldb, sendAndReceiveData.To)
|
||||
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
accountNonce := strconv.FormatUint(tx.Nonce(), 10)
|
||||
CreateAccount(sqldb, sendAndReceiveData.To, sendAndReceiveData.Amount, accountNonce)
|
||||
case err != nil:
|
||||
log.Fatal(err)
|
||||
default:
|
||||
fromAddressBalance, fromAccountNonce, err := AccountExists(sqldb, sendAndReceiveData.From)
|
||||
func balanceHelper(sqldb *sql.DB, s stypes.SendAndReceive, amount string) {
|
||||
fromAddressBalance, fromAccountNonce, err := AccountExists(sqldb, s.From)
|
||||
toAddressBalance, toAccountNonce, err := AccountExists(sqldb, s.To)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -268,26 +189,29 @@ func swriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
|||
//BALANCES TO AND FROM ADDR
|
||||
toBalance := new(big.Int)
|
||||
toBalance, _ = toBalance.SetString(toAddressBalance, 10)
|
||||
|
||||
fromBalance := new(big.Int)
|
||||
fromBalance, _ = fromBalance.SetString(fromAddressBalance, 10)
|
||||
|
||||
amountValue := new(big.Int)
|
||||
amountValue, _ = amountValue.SetString(amount, 10)
|
||||
|
||||
//ACCOUNT NONCES
|
||||
toNonce := new(big.Int)
|
||||
toNonce, _ = toNonce.SetString(toAccountNonce, 10)
|
||||
|
||||
fromNonce := new(big.Int)
|
||||
fromNonce, _ = fromNonce.SetString(fromAccountNonce, 10)
|
||||
|
||||
newBalanceReceiver.Add(toBalance, tx.Value())
|
||||
newBalanceSender.Sub(fromBalance, tx.Value())
|
||||
newBalanceReceiver.Add(toBalance, amountValue)
|
||||
newBalanceSender.Sub(fromBalance, amountValue)
|
||||
|
||||
newAccountNonceReceiver.Add(toNonce, nonceIncrement)
|
||||
newAccountNonceSender.Add(fromNonce, nonceIncrement)
|
||||
|
||||
//UPDATE ACCOUNTS BASED ON NEW BALANCES AND ACCOUNT NONCES
|
||||
UpdateAccount(sqldb, sendAndReceiveData.To, newBalanceReceiver.String(), newAccountNonceReceiver.String())
|
||||
UpdateAccount(sqldb, sendAndReceiveData.From, newBalanceSender.String(), newAccountNonceSender.String())
|
||||
}
|
||||
return nil
|
||||
UpdateAccount(sqldb, s.To, newBalanceReceiver.String(), newAccountNonceReceiver.String())
|
||||
UpdateAccount(sqldb, s.From, newBalanceSender.String(), newAccountNonceSender.String())
|
||||
}
|
||||
|
||||
// @NOTE: This function is extremely complex and requires heavy testing and knowdlege of edge cases:
|
||||
|
|
@ -378,19 +302,21 @@ func sstoreReward(sqldb *sql.DB, address string, reward *big.Int) {
|
|||
///////////////////////
|
||||
//DB Utility functions
|
||||
//////////////////////
|
||||
|
||||
//CreateAccount writes new account to Postgres Db
|
||||
func CreateAccount(sqldb *sql.DB, addr string, balance string, accountNonce string) {
|
||||
sqlStatement := `INSERT INTO accounts(addr, balance, accountNonce) VALUES(($1), ($2), ($3)) RETURNING addr`
|
||||
insertErr := sqldb.QueryRow(sqlStatement, addr, balance, accountNonce).Scan(&addr)
|
||||
insertErr := sqldb.QueryRow(sqlStatement, strings.ToLower(addr), balance, accountNonce).Scan(&addr)
|
||||
if insertErr != nil {
|
||||
panic(insertErr)
|
||||
}
|
||||
}
|
||||
|
||||
//AccountExists checks if account exists in Postgres Db
|
||||
func AccountExists(sqldb *sql.DB, addr string) (string, string, error) {
|
||||
var addressBalance, accountNonce string
|
||||
sqlExistsStatement := `SELECT balance, accountNonce from accounts WHERE addr = ($1)`
|
||||
err := sqldb.QueryRow(sqlExistsStatement, addr).Scan(&addressBalance, &accountNonce)
|
||||
|
||||
err := sqldb.QueryRow(sqlExistsStatement, strings.ToLower(addr)).Scan(&addressBalance, &accountNonce)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
return addressBalance, accountNonce, err
|
||||
|
|
@ -401,30 +327,55 @@ func AccountExists (sqldb *sql.DB, addr string) (string, string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
//BlockExists checks if block exists in Postgres Db
|
||||
func BlockExists(sqldb *sql.DB, hash string) error {
|
||||
var res string
|
||||
sqlExistsStatement := `SELECT hash from blocks WHERE hash= ($1)`
|
||||
err := sqldb.QueryRow(sqlExistsStatement, strings.ToLower(hash)).Scan(&res)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
return err
|
||||
panic(err)
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
//UpdateAccount updates account in Postgres Db
|
||||
func UpdateAccount(sqldb *sql.DB, addr string, balance string, accountNonce string) {
|
||||
updateSQLStatement := `UPDATE accounts SET balance = ($2), accountNonce = ($3) WHERE addr = ($1)`
|
||||
_, updateErr := sqldb.Exec(updateSQLStatement, addr, balance, accountNonce)
|
||||
_, updateErr := sqldb.Exec(updateSQLStatement, strings.ToLower(addr), balance, accountNonce)
|
||||
if updateErr != nil {
|
||||
panic(updateErr)
|
||||
}
|
||||
}
|
||||
|
||||
func InsertBlock(sqldb *sql.DB, blockData SBlock, blockAge SBlock) {
|
||||
//InsertBlock writes block to Postgres Db
|
||||
func InsertBlock(sqldb *sql.DB, blockData stypes.SBlock) {
|
||||
sqlStatement := `INSERT INTO blocks(hash, coinbase, number, gasUsed, gasLimit, txCount, uncleCount, age, parentHash, uncleHash, difficulty, size, rewards, nonce) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12),($13), ($14)) RETURNING number`
|
||||
qerr := sqldb.QueryRow(sqlStatement, blockData.Hash, blockData.Coinbase, blockData.Number, blockData.GasUsed, blockData.GasLimit, blockData.TxCount, blockData.UncleCount, blockAge.Age, blockData.ParentHash, blockData.UncleHash, blockData.Difficulty, blockData.Size, blockData.Rewards, blockData.Nonce).Scan(&blockData.Number)
|
||||
qerr := sqldb.QueryRow(sqlStatement, strings.ToLower(blockData.Hash), blockData.Coinbase, blockData.Number, blockData.GasUsed, blockData.GasLimit, blockData.TxCount, blockData.UncleCount, blockData.Age, blockData.ParentHash, blockData.UncleHash, blockData.Difficulty, blockData.Size, blockData.Rewards, blockData.Nonce).Scan(&blockData.Number)
|
||||
if qerr != nil {
|
||||
panic(qerr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func InsertTx (sqldb *sql.DB, txData ShyftTxEntryPretty, data ShyftTxEntryPretty) {
|
||||
//InsertTx writes tx to Postgres Db
|
||||
func InsertTx(sqldb *sql.DB, txData stypes.ShyftTxEntryPretty) {
|
||||
var retNonce string
|
||||
sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, gasLimit, txfee, nonce, isContract, txStatus, age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce`
|
||||
err := sqldb.QueryRow(sqlStatement, txData.TxHash, txData.From, data.To.String(), txData.BlockHash, txData.BlockNumber, txData.Amount, txData.GasPrice, txData.Gas, txData.GasLimit, txData.Cost, txData.Nonce, data.IsContract, data.Status, txData.Age, txData.Data).Scan(&retNonce)
|
||||
err := sqldb.QueryRow(sqlStatement, strings.ToLower(txData.TxHash), strings.ToLower(txData.From), strings.ToLower(txData.To.String()), strings.ToLower(txData.BlockHash), txData.BlockNumber, txData.Amount, txData.GasPrice, txData.Gas, txData.GasLimit, txData.Cost, txData.Nonce, txData.IsContract, txData.Status, txData.Age, txData.Data).Scan(&retNonce)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//InsertInternalTx writes internal tx to Postgres Db
|
||||
func InsertInternalTx(sqldb *sql.DB, i stypes.InteralWrite) {
|
||||
var returnValue string
|
||||
sqlStatement := `INSERT INTO internaltxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10)) RETURNING txHash`
|
||||
qerr := sqldb.QueryRow(sqlStatement, i.Type, strings.ToLower(i.Hash), strings.ToLower(i.From), strings.ToLower(i.To), i.Value, i.Gas, i.GasUsed, i.Time, i.Input, i.Output).Scan(&returnValue)
|
||||
if qerr != nil {
|
||||
fmt.Println(qerr)
|
||||
panic(qerr)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
stypes "github.com/ShyftNetwork/go-empyrean/core/sTypes"
|
||||
)
|
||||
|
||||
///////////
|
||||
// Getters
|
||||
//////////
|
||||
func SGetAllBlocks(sqldb *sql.DB) string {
|
||||
var arr blockRes
|
||||
var arr stypes.BlockRes
|
||||
var blockArr string
|
||||
rows, err := sqldb.Query(`SELECT * FROM blocks`)
|
||||
if err != nil {
|
||||
|
|
@ -25,9 +27,9 @@ func SGetAllBlocks(sqldb *sql.DB) string {
|
|||
var txCount, uncleCount int
|
||||
|
||||
err = rows.Scan(
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num,)
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num)
|
||||
|
||||
arr.Blocks = append(arr.Blocks, SBlock{
|
||||
arr.Blocks = append(arr.Blocks, stypes.SBlock{
|
||||
Hash: hash,
|
||||
Coinbase: coinbase,
|
||||
GasUsed: gasUsed,
|
||||
|
|
@ -61,9 +63,9 @@ func SGetBlock(sqldb *sql.DB, blockNumber string) string {
|
|||
var txCount, uncleCount int
|
||||
|
||||
row.Scan(
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num,)
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num)
|
||||
|
||||
block := SBlock{
|
||||
block := stypes.SBlock{
|
||||
Hash: hash,
|
||||
Coinbase: coinbase,
|
||||
GasUsed: gasUsed,
|
||||
|
|
@ -91,9 +93,9 @@ func SGetRecentBlock(sqldb *sql.DB) string {
|
|||
var txCount, uncleCount int
|
||||
|
||||
row.Scan(
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num,)
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num)
|
||||
|
||||
block := SBlock{
|
||||
block := stypes.SBlock{
|
||||
Hash: hash,
|
||||
Coinbase: coinbase,
|
||||
GasUsed: gasUsed,
|
||||
|
|
@ -114,7 +116,7 @@ func SGetRecentBlock(sqldb *sql.DB) string {
|
|||
}
|
||||
|
||||
func SGetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
||||
var arr txRes
|
||||
var arr stypes.TxRes
|
||||
var txx string
|
||||
sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1`
|
||||
rows, err := sqldb.Query(sqlStatement, blockNumber)
|
||||
|
|
@ -133,7 +135,7 @@ func SGetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
|||
&txhash, &to_addr, &from_addr, &blockhash, &blocknumber, &amount, &gasprice, &gas, &gasLimit, &txfee, &nonce, &status, &isContract, &age, &data,
|
||||
)
|
||||
|
||||
arr.TxEntry = append(arr.TxEntry, ShyftTxEntryPretty{
|
||||
arr.TxEntry = append(arr.TxEntry, stypes.ShyftTxEntryPretty{
|
||||
TxHash: txhash,
|
||||
ToGet: to_addr,
|
||||
From: from_addr,
|
||||
|
|
@ -159,7 +161,7 @@ func SGetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
|||
}
|
||||
|
||||
func SGetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
|
||||
var arr blockRes
|
||||
var arr stypes.BlockRes
|
||||
var blockArr string
|
||||
sqlStatement := `SELECT * FROM blocks WHERE coinbase=$1`
|
||||
rows, err := sqldb.Query(sqlStatement, coinbase)
|
||||
|
|
@ -174,9 +176,9 @@ func SGetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
|
|||
var txCount, uncleCount int
|
||||
|
||||
err = rows.Scan(
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num,)
|
||||
&hash, &coinbase, &gasUsed, &gasLimit, &txCount, &uncleCount, &age, &parentHash, &uncleHash, &difficulty, &size, &nonce, &rewards, &num)
|
||||
|
||||
arr.Blocks = append(arr.Blocks, SBlock{
|
||||
arr.Blocks = append(arr.Blocks, stypes.SBlock{
|
||||
Hash: hash,
|
||||
Coinbase: coinbase,
|
||||
GasUsed: gasUsed,
|
||||
|
|
@ -202,7 +204,7 @@ func SGetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
|
|||
|
||||
//GetAllTransactions getter fn for API
|
||||
func SGetAllTransactions(sqldb *sql.DB) string {
|
||||
var arr txRes
|
||||
var arr stypes.TxRes
|
||||
var txx string
|
||||
rows, err := sqldb.Query(`SELECT * FROM txs`)
|
||||
if err != nil {
|
||||
|
|
@ -220,7 +222,7 @@ func SGetAllTransactions(sqldb *sql.DB) string {
|
|||
&txhash, &to_addr, &from_addr, &blockhash, &blocknumber, &amount, &gasprice, &gas, &gasLimit, &txfee, &nonce, &status, &isContract, &age, &data,
|
||||
)
|
||||
|
||||
arr.TxEntry = append(arr.TxEntry, ShyftTxEntryPretty{
|
||||
arr.TxEntry = append(arr.TxEntry, stypes.ShyftTxEntryPretty{
|
||||
TxHash: txhash,
|
||||
ToGet: to_addr,
|
||||
From: from_addr,
|
||||
|
|
@ -258,7 +260,7 @@ func SGetTransaction(sqldb *sql.DB, txHash string) string {
|
|||
row.Scan(
|
||||
&txhash, &to_addr, &from_addr, &blockhash, &blocknumber, &amount, &gasprice, &gas, &gasLimit, &txfee, &nonce, &status, &isContract, &age, &data)
|
||||
|
||||
tx := ShyftTxEntryPretty{
|
||||
tx := stypes.ShyftTxEntryPretty{
|
||||
TxHash: txhash,
|
||||
ToGet: to_addr,
|
||||
From: from_addr,
|
||||
|
|
@ -280,14 +282,14 @@ func SGetTransaction(sqldb *sql.DB, txHash string) string {
|
|||
return string(json)
|
||||
}
|
||||
|
||||
func InnerSGetAccount(sqldb *sql.DB, address string) (SAccounts, bool) {
|
||||
func InnerSGetAccount(sqldb *sql.DB, address string) (stypes.SAccounts, bool) {
|
||||
sqlStatement := `SELECT * FROM accounts WHERE addr=$1;`
|
||||
var addr, balance, accountNonce string
|
||||
err := sqldb.QueryRow(sqlStatement, address).Scan(&addr, &balance, &accountNonce)
|
||||
if err == sql.ErrNoRows {
|
||||
return SAccounts{}, false
|
||||
return stypes.SAccounts{}, false
|
||||
} else {
|
||||
account := SAccounts{
|
||||
account := stypes.SAccounts{
|
||||
Addr: addr,
|
||||
Balance: balance,
|
||||
AccountNonce: accountNonce,
|
||||
|
|
@ -305,7 +307,7 @@ func SGetAccount(sqldb *sql.DB, address string) string {
|
|||
|
||||
//GetAllAccounts returns all accounts and balances
|
||||
func SGetAllAccounts(sqldb *sql.DB) string {
|
||||
var array accountRes
|
||||
var array stypes.AccountRes
|
||||
var accountsArr, accountNonce string
|
||||
|
||||
accs, err := sqldb.Query(`
|
||||
|
|
@ -326,7 +328,7 @@ func SGetAllAccounts(sqldb *sql.DB) string {
|
|||
&addr, &balance, &accountNonce,
|
||||
)
|
||||
|
||||
array.AllAccounts = append(array.AllAccounts, SAccounts{
|
||||
array.AllAccounts = append(array.AllAccounts, stypes.SAccounts{
|
||||
Addr: addr,
|
||||
Balance: balance,
|
||||
AccountNonce: accountNonce,
|
||||
|
|
@ -341,7 +343,7 @@ func SGetAllAccounts(sqldb *sql.DB) string {
|
|||
|
||||
//GetAccount returns account balances
|
||||
func SGetAccountTxs(sqldb *sql.DB, address string) string {
|
||||
var arr txRes
|
||||
var arr stypes.TxRes
|
||||
var txx string
|
||||
sqlStatement := `SELECT * FROM txs WHERE to_addr=$1 OR from_addr=$1;`
|
||||
rows, err := sqldb.Query(sqlStatement, address)
|
||||
|
|
@ -360,7 +362,7 @@ func SGetAccountTxs(sqldb *sql.DB, address string) string {
|
|||
&txhash, &to_addr, &from_addr, &blockhash, &blocknumber, &amount, &gasprice, &gas, &gasLimit, &txfee, &nonce, &status, &isContract, &age, &data,
|
||||
)
|
||||
|
||||
arr.TxEntry = append(arr.TxEntry, ShyftTxEntryPretty{
|
||||
arr.TxEntry = append(arr.TxEntry, stypes.ShyftTxEntryPretty{
|
||||
TxHash: txhash,
|
||||
ToGet: to_addr,
|
||||
From: from_addr,
|
||||
|
|
|
|||
|
|
@ -631,8 +631,6 @@ func (api *PrivateDebugAPI) StraceTx(ctx context.Context, message core.Message,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// traceTx configures a new tracer according to the provided configuration, and
|
||||
// executes the given message in the provided environment. The return value will
|
||||
// be tracer dependent.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package eth
|
||||
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/params"
|
||||
"context"
|
||||
)
|
||||
|
||||
var EthereumObject interface{}
|
||||
|
|
|
|||
|
|
@ -25,14 +25,16 @@ import (
|
|||
"time"
|
||||
"unsafe"
|
||||
|
||||
"strconv"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/common/hexutil"
|
||||
"github.com/ShyftNetwork/go-empyrean/core"
|
||||
stypes "github.com/ShyftNetwork/go-empyrean/core/sTypes"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/vm"
|
||||
"github.com/ShyftNetwork/go-empyrean/crypto"
|
||||
"github.com/ShyftNetwork/go-empyrean/log"
|
||||
"gopkg.in/olebedev/go-duktape.v3"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.
|
||||
|
|
@ -603,14 +605,21 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) {
|
|||
value, _ := hexutil.DecodeUint64(i.Value)
|
||||
amount := strconv.FormatUint(value, 10)
|
||||
|
||||
var returnValue string
|
||||
sqlStatement := `INSERT INTO internaltxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10)) RETURNING txHash`
|
||||
qerr := sqldb.QueryRow(sqlStatement, i.Type, hash.Hex(), i.From, i.To, amount, gas, gasUsed, i.Time, i.Input, i.Output).Scan(&returnValue)
|
||||
|
||||
if qerr != nil {
|
||||
fmt.Println(qerr)
|
||||
panic(qerr)
|
||||
iTx := stypes.InteralWrite{
|
||||
Hash: hash.Hex(),
|
||||
Type: i.Type,
|
||||
From: i.From,
|
||||
To: i.To,
|
||||
Value: amount,
|
||||
Gas: gas,
|
||||
GasUsed: gasUsed,
|
||||
Input: i.Input,
|
||||
Output: i.Output,
|
||||
Time: i.Time,
|
||||
}
|
||||
//@TODO WRITE OVER TRANSACTION STRUCT
|
||||
core.SWriteInternalTxBalances(sqldb, i.To, i.From, amount)
|
||||
core.InsertInternalTx(sqldb, iTx)
|
||||
}
|
||||
|
||||
//@NOTE:SHYFT
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import (
|
|||
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/core"
|
||||
"github.com/gorilla/mux"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// GetTransaction gets txs
|
||||
|
|
@ -239,7 +240,7 @@ func BroadcastTx(w http.ResponseWriter, r *http.Request) {
|
|||
fmt.Fprintln(w, "ERROR parsing json")
|
||||
}
|
||||
tx_hash := dat["result"]
|
||||
if(tx_hash == nil) {
|
||||
if tx_hash == nil {
|
||||
errMap := dat["error"].(map[string]interface{})
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ class AccountTable extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
|
||||
let startNum = 1;
|
||||
const sorted = [...this.state.data];
|
||||
sorted.sort((a, b) => Number(a.Balance) > Number(b.Balance));
|
||||
|
|
@ -38,7 +37,7 @@ class AccountTable extends Component {
|
|||
Percentage={percentage.toFixed(2)}
|
||||
Addr={data.Addr}
|
||||
Balance={conversion}
|
||||
AcountNonce={data.AccountNonce}
|
||||
AccountNonce={data.AccountNonce}
|
||||
detailAccountHandler={this.props.detailAccountHandler}
|
||||
/>
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class AccountTransactionTable extends Component {
|
|||
age={data.Age}
|
||||
txHash={data.TxHash}
|
||||
blockNumber={data.BlockNumber}
|
||||
to={data.To}
|
||||
to={data.ToGet}
|
||||
from={data.From}
|
||||
value={amountConversion}
|
||||
cost={costConversion}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class BlocksTable extends Component {
|
|||
Hash={data.Hash}
|
||||
Number={data.Number}
|
||||
Coinbase={data.Coinbase}
|
||||
Age={data.Age}
|
||||
AgeGet={data.AgeGet}
|
||||
GasUsed={data.GasUsed}
|
||||
GasLimit={data.GasLimit}
|
||||
UncleCount={data.UncleCount}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const BlockTable = (props) => {
|
|||
{props.Number}
|
||||
</Link></td>
|
||||
<td className={classes.addressTag}>{props.Hash}</td>
|
||||
<td>{props.Age}</td>
|
||||
<td>{props.AgeGet}</td>
|
||||
<td>{props.TxCount}</td>
|
||||
<td>{props.UncleCount}</td>
|
||||
<td className={classes.addressTag}><Link to="/mined/blocks" onClick={() => props.getBlocksMined(props.Coinbase)}>{props.Coinbase}</Link></td>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class DetailBlockTable extends Component {
|
|||
</tr>
|
||||
<tr>
|
||||
<th scope="col">Age:</th>
|
||||
<td>{data.Age}</td>
|
||||
<td>{data.AgeGet}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col">Txn:</th>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class BlocksMinedTable extends Component {
|
|||
Hash={data.Hash}
|
||||
Number={data.Number}
|
||||
Coinbase={data.Coinbase}
|
||||
Age={data.Age}
|
||||
AgeGet={data.AgeGet}
|
||||
GasUsed={data.GasUsed}
|
||||
GasLimit={data.GasLimit}
|
||||
UncleCount={data.UncleCount}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const MinedBlockTable = (props) => {
|
|||
{props.Number}
|
||||
</Link></td>
|
||||
<td className={classes.addressTag}>{props.Hash}</td>
|
||||
<td>{props.Age}</td>
|
||||
<td>{props.AgeGet}</td>
|
||||
<td>{props.TxCount}</td>
|
||||
<td>{props.UncleCount}</td>
|
||||
<td className={classes.addressTag}>{props.Coinbase}</td>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class DetailTransactionTable extends Component {
|
|||
</tr>
|
||||
<tr>
|
||||
<th scope="col">To:</th>
|
||||
<td>{ `${data.IsContract}` ? `${data.To} (Contract)` : `${data.To}` }</td>
|
||||
<td>{ `${data.IsContract}` ? `${data.ToGet} (Contract)` : `${data.ToGet}` }</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col">Value:</th>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TransactionTable extends Component {
|
|||
age={data.Age}
|
||||
txHash={data.TxHash}
|
||||
blockNumber={data.BlockNumber}
|
||||
to={data.To}
|
||||
to={data.ToGet}
|
||||
from={data.From}
|
||||
value={data.Amount}
|
||||
cost={conversion}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS blocks (
|
|||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS txs (
|
||||
txHash text,
|
||||
txHash text primary key unique,
|
||||
to_addr text,
|
||||
from_addr text,
|
||||
blockhash text references blocks(hash),
|
||||
|
|
@ -36,5 +36,19 @@ CREATE TABLE IF NOT EXISTS txs (
|
|||
CREATE TABLE IF NOT EXISTS accounts (
|
||||
addr text primary key unique,
|
||||
balance numeric,
|
||||
accountnonce numeric
|
||||
accountNonce numeric
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS internalTxs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
txHash text references txs(txHash),
|
||||
type text,
|
||||
to_addr text,
|
||||
from_addr text,
|
||||
amount text,
|
||||
gas numeric,
|
||||
gasUsed numeric,
|
||||
time text,
|
||||
input text,
|
||||
output text
|
||||
)
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
DROP TABLE internalTxs;
|
||||
DROP TABLE txs;
|
||||
DROP TABLE blocks;
|
||||
DROP TABLE accounts;
|
||||
|
|
@ -1,17 +1,19 @@
|
|||
package shyftdb
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/common"
|
||||
"github.com/ShyftNetwork/go-empyrean/consensus/ethash"
|
||||
"github.com/ShyftNetwork/go-empyrean/core"
|
||||
"github.com/ShyftNetwork/go-empyrean/core/types"
|
||||
"github.com/ShyftNetwork/go-empyrean/eth"
|
||||
"math/big"
|
||||
//"time"
|
||||
"encoding/json"
|
||||
"github.com/ShyftNetwork/go-empyrean/crypto"
|
||||
"github.com/ShyftNetwork/go-empyrean/consensus/ethash"
|
||||
"strconv"
|
||||
"github.com/ShyftNetwork/go-empyrean/eth"
|
||||
)
|
||||
|
||||
type ShyftTracer struct{}
|
||||
|
|
@ -21,10 +23,11 @@ const (
|
|||
)
|
||||
|
||||
func TestBlock(t *testing.T) {
|
||||
//SET UP FOR TEST FUNCTIONS
|
||||
eth.NewShyftTestLDB()
|
||||
core.InitDBTest()
|
||||
shyft_tracer := new(eth.ShyftTracer)
|
||||
core.SetIShyftTracer(shyft_tracer)
|
||||
shyftTracer := new(eth.ShyftTracer)
|
||||
core.SetIShyftTracer(shyftTracer)
|
||||
|
||||
ethConf := ð.Config{
|
||||
Genesis: core.DeveloperGenesisBlock(15, common.Address{}),
|
||||
|
|
@ -37,19 +40,25 @@ func TestBlock(t *testing.T) {
|
|||
eth.SetGlobalConfig(ethConf)
|
||||
|
||||
eth.InitTracerEnv()
|
||||
core.ClearTables()
|
||||
|
||||
t.Run("TestBlockToReturnBlock", func(t *testing.T) {
|
||||
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
signer := types.NewEIP155Signer(big.NewInt(2147483647))
|
||||
|
||||
//Nonce, To Address,Value, GasLimit, Gasprice, data
|
||||
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx,_ := types.SignTx(tx1, signer, key)
|
||||
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22})
|
||||
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(5), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx1, _ := types.SignTx(tx1, signer, key)
|
||||
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(5), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22})
|
||||
mytx2, _ := types.SignTx(tx2, signer, key)
|
||||
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33})
|
||||
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(5), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33})
|
||||
mytx3, _ := types.SignTx(tx3, signer, key)
|
||||
txs := []*types.Transaction{mytx, mytx2, mytx3}
|
||||
txs := []*types.Transaction{mytx1, mytx2}
|
||||
txs1 := []*types.Transaction{mytx3}
|
||||
|
||||
//Nonce,Value, GasLimit, Gasprice, data
|
||||
contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx4, _ := types.SignTx(contractCreation, signer, key)
|
||||
txs2 := []*types.Transaction{mytx4}
|
||||
|
||||
receipt := &types.Receipt{
|
||||
Status: types.ReceiptStatusSuccessful,
|
||||
|
|
@ -62,102 +71,25 @@ func TestBlock(t *testing.T) {
|
|||
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
|
||||
GasUsed: 111111,
|
||||
}
|
||||
|
||||
receipts := []*types.Receipt{receipt}
|
||||
block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts)
|
||||
|
||||
// Write and verify the block in the database
|
||||
if err := core.SWriteBlock(block, receipts); err != nil {
|
||||
t.Fatalf("Failed to write block into database: %v", err)
|
||||
}
|
||||
block1 := types.NewBlock(&types.Header{Number: big.NewInt(323)}, txs, nil, receipts)
|
||||
block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts)
|
||||
block3 := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs2, nil, receipts)
|
||||
blocks := []*types.Block{block1, block2, block3}
|
||||
|
||||
sqldb, err := core.DBConnection()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
entry := core.SGetBlock(sqldb, block.Number().String())
|
||||
byt := []byte(entry)
|
||||
var data core.SBlock
|
||||
json.Unmarshal(byt, &data)
|
||||
|
||||
//TODO Difficulty, rewards, age
|
||||
if block.Hash().String() != data.Hash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String())
|
||||
}
|
||||
if block.Coinbase().String() != data.Coinbase {
|
||||
t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String())
|
||||
}
|
||||
if block.Number().String() != data.Number {
|
||||
t.Fatalf("Block number [%v]: Block number not found", block.Number().String())
|
||||
}
|
||||
if block.GasUsed() != data.GasUsed {
|
||||
t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed())
|
||||
}
|
||||
if block.GasLimit() != data.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit())
|
||||
}
|
||||
if block.Transactions().Len() != data.TxCount {
|
||||
t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len())
|
||||
}
|
||||
if len(block.Uncles()) != data.UncleCount {
|
||||
t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles()))
|
||||
}
|
||||
if block.ParentHash().String() != data.ParentHash {
|
||||
t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String())
|
||||
}
|
||||
if block.UncleHash().String() != data.UncleHash {
|
||||
t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String())
|
||||
}
|
||||
if block.Size().String() != data.Size {
|
||||
t.Fatalf("Size [%v]: Size not found", block.Size().String())
|
||||
}
|
||||
if block.Nonce() != data.Nonce {
|
||||
t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce())
|
||||
}
|
||||
|
||||
if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 {
|
||||
t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks)
|
||||
}
|
||||
|
||||
if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 {
|
||||
t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress)
|
||||
}
|
||||
|
||||
ClearTables()
|
||||
})
|
||||
|
||||
t.Run("TestGetRecentBlock", func(t *testing.T) {
|
||||
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
signer := types.NewEIP155Signer(big.NewInt(2147483647))
|
||||
|
||||
//Nonce, To Address,Value, GasLimit, Gasprice, data
|
||||
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx,_ := types.SignTx(tx1, signer, key)
|
||||
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22})
|
||||
mytx2,_ := types.SignTx(tx2, signer, key)
|
||||
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33})
|
||||
mytx3,_ := types.SignTx(tx3, signer, key)
|
||||
txs := []*types.Transaction{mytx, mytx2}
|
||||
txs1 := []*types.Transaction{mytx3}
|
||||
|
||||
receipt1 := &types.Receipt{
|
||||
Status: types.ReceiptStatusSuccessful,
|
||||
CumulativeGasUsed: 1,
|
||||
Logs: []*types.Log{
|
||||
{Address: common.BytesToAddress([]byte{0x11})},
|
||||
{Address: common.BytesToAddress([]byte{0x01, 0x11})},
|
||||
},
|
||||
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
|
||||
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
|
||||
GasUsed: 111111,
|
||||
}
|
||||
|
||||
receipts := []*types.Receipt{receipt1}
|
||||
block := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs, nil, receipts)
|
||||
block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts)
|
||||
blocks := []*types.Block{block, block2}
|
||||
fromAddr := "0x71562b71999873db5b286df957af199ec94617f7"
|
||||
fromAddrEndBalance := "75"
|
||||
fromAddrEndNonce := "5"
|
||||
toAddr := common.BytesToAddress([]byte{0x11})
|
||||
core.CreateAccount(sqldb, fromAddr, "201", "1")
|
||||
|
||||
t.Run("TestBlockToReturnBlock", func(t *testing.T) {
|
||||
for _, bc := range blocks {
|
||||
// Write and verify the block in the database
|
||||
if err := core.SWriteBlock(bc, receipts); err != nil {
|
||||
|
|
@ -165,96 +97,107 @@ func TestBlock(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
sqldb, err := core.DBConnection()
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
entry := core.SGetBlock(sqldb, block1.Number().String())
|
||||
byt := []byte(entry)
|
||||
var data core.SBlock
|
||||
json.Unmarshal(byt, &data)
|
||||
|
||||
//TODO Difficulty, rewards, age
|
||||
if block1.Hash().String() != data.Hash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block1.Hash().String())
|
||||
}
|
||||
if block1.Coinbase().String() != data.Coinbase {
|
||||
t.Fatalf("Block coinbase [%v]: Block coinbase not found", block1.Coinbase().String())
|
||||
}
|
||||
if block1.Number().String() != data.Number {
|
||||
t.Fatalf("Block number [%v]: Block number not found", block1.Number().String())
|
||||
}
|
||||
if block1.GasUsed() != data.GasUsed {
|
||||
t.Fatalf("Gas Used [%v]: Gas used not found", block1.GasUsed())
|
||||
}
|
||||
if block1.GasLimit() != data.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block1.GasLimit())
|
||||
}
|
||||
if block1.Transactions().Len() != data.TxCount {
|
||||
t.Fatalf("Tx Count [%v]: Tx Count not found", block1.Transactions().Len())
|
||||
}
|
||||
if len(block1.Uncles()) != data.UncleCount {
|
||||
t.Fatalf("Uncle count [%v]: Uncle count not found", len(block1.Uncles()))
|
||||
}
|
||||
if block1.ParentHash().String() != data.ParentHash {
|
||||
t.Fatalf("Parent hash [%v]: Parent hash not found", block1.ParentHash().String())
|
||||
}
|
||||
if block1.UncleHash().String() != data.UncleHash {
|
||||
t.Fatalf("Uncle hash [%v]: Uncle hash not found", block1.UncleHash().String())
|
||||
}
|
||||
if block1.Size().String() != data.Size {
|
||||
t.Fatalf("Size [%v]: Size not found", block1.Size().String())
|
||||
}
|
||||
if block1.Nonce() != data.Nonce {
|
||||
t.Fatalf("Block nonce [%v]: Block nonce not found", block1.Nonce())
|
||||
}
|
||||
|
||||
if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 {
|
||||
t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks)
|
||||
}
|
||||
|
||||
if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block1.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 {
|
||||
t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("TestGetRecentBlock", func(t *testing.T) {
|
||||
response := core.SGetRecentBlock(sqldb)
|
||||
byteRes := []byte(response)
|
||||
var recentBlock core.SBlock
|
||||
json.Unmarshal(byteRes, &recentBlock)
|
||||
|
||||
if block.Hash().String() != recentBlock.Hash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String())
|
||||
if block1.Hash().String() != recentBlock.Hash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block1.Hash().String())
|
||||
}
|
||||
if block.Coinbase().String() != recentBlock.Coinbase {
|
||||
t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String())
|
||||
if block1.Coinbase().String() != recentBlock.Coinbase {
|
||||
t.Fatalf("Block coinbase [%v]: Block coinbase not found", block1.Coinbase().String())
|
||||
}
|
||||
if block.Number().String() != recentBlock.Number {
|
||||
t.Fatalf("Block number [%v]: Block number not found", block.Number().String())
|
||||
if block1.Number().String() != recentBlock.Number {
|
||||
t.Fatalf("Block number [%v]: Block number not found", block1.Number().String())
|
||||
}
|
||||
if block.GasUsed() != recentBlock.GasUsed {
|
||||
t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed())
|
||||
if block1.GasUsed() != recentBlock.GasUsed {
|
||||
t.Fatalf("Gas Used [%v]: Gas used not found", block1.GasUsed())
|
||||
}
|
||||
if block.GasLimit() != recentBlock.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit())
|
||||
if block1.GasLimit() != recentBlock.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block1.GasLimit())
|
||||
}
|
||||
if block.Transactions().Len() != recentBlock.TxCount {
|
||||
t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len())
|
||||
if block1.Transactions().Len() != recentBlock.TxCount {
|
||||
t.Fatalf("Tx Count [%v]: Tx Count not found", block1.Transactions().Len())
|
||||
}
|
||||
if len(block.Uncles()) != recentBlock.UncleCount {
|
||||
t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles()))
|
||||
if len(block1.Uncles()) != recentBlock.UncleCount {
|
||||
t.Fatalf("Uncle count [%v]: Uncle count not found", len(block1.Uncles()))
|
||||
}
|
||||
if block.ParentHash().String() != recentBlock.ParentHash {
|
||||
t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String())
|
||||
if block1.ParentHash().String() != recentBlock.ParentHash {
|
||||
t.Fatalf("Parent hash [%v]: Parent hash not found", block1.ParentHash().String())
|
||||
}
|
||||
if block.UncleHash().String() != recentBlock.UncleHash {
|
||||
t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String())
|
||||
if block1.UncleHash().String() != recentBlock.UncleHash {
|
||||
t.Fatalf("Uncle hash [%v]: Uncle hash not found", block1.UncleHash().String())
|
||||
}
|
||||
if block.Size().String() != recentBlock.Size {
|
||||
t.Fatalf("Size [%v]: Size not found", block.Size().String())
|
||||
if block1.Size().String() != recentBlock.Size {
|
||||
t.Fatalf("Size [%v]: Size not found", block1.Size().String())
|
||||
}
|
||||
if block.Nonce() != recentBlock.Nonce {
|
||||
t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce())
|
||||
if block1.Nonce() != recentBlock.Nonce {
|
||||
t.Fatalf("Block nonce [%v]: Block nonce not found", block1.Nonce())
|
||||
}
|
||||
|
||||
if allTxsFromBlock := core.SGetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 {
|
||||
t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock)
|
||||
}
|
||||
ClearTables()
|
||||
})
|
||||
|
||||
//
|
||||
t.Run("TestContractCreationTx", func(t *testing.T) {
|
||||
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
signer := types.NewEIP155Signer(big.NewInt(2147483647))
|
||||
|
||||
//Nonce,Value, GasLimit, Gasprice, data
|
||||
contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx,_ := types.SignTx(contractCreation, signer, key)
|
||||
txs := []*types.Transaction{mytx}
|
||||
|
||||
receipt2 := &types.Receipt{
|
||||
Status: types.ReceiptStatusSuccessful,
|
||||
CumulativeGasUsed: 1,
|
||||
Logs: []*types.Log{
|
||||
{Address: common.BytesToAddress([]byte{0x11})},
|
||||
{Address: common.BytesToAddress([]byte{0x01, 0x11})},
|
||||
},
|
||||
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
|
||||
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
|
||||
GasUsed: 111111,
|
||||
}
|
||||
|
||||
receipts := []*types.Receipt{receipt2}
|
||||
block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts)
|
||||
|
||||
if err := core.SWriteBlock(block, receipts); err != nil {
|
||||
t.Fatalf("Failed to write block into database: %v", err)
|
||||
}
|
||||
|
||||
var contractAddressFromReciept string
|
||||
for _, receipt := range receipts {
|
||||
contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String()
|
||||
}
|
||||
|
||||
sqldb, err := core.DBConnection()
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, tx := range txs {
|
||||
for _, tx := range txs2 {
|
||||
txn := core.SGetTransaction(sqldb, tx.Hash().String())
|
||||
byt := []byte(txn)
|
||||
var data core.ShyftTxEntryPretty
|
||||
|
|
@ -266,7 +209,7 @@ t.Run("TestContractCreationTx", func (t *testing.T) {
|
|||
if contractAddressFromReciept != data.ToGet {
|
||||
t.Fatalf("Contract Addr [%v]: Contract addr not found", contractAddressFromReciept)
|
||||
}
|
||||
if tx.From().String() != data.From {
|
||||
if strings.ToLower(tx.From().String()) != data.From {
|
||||
t.Fatalf("From Addr [%v]: From addr not found", tx.From().String())
|
||||
}
|
||||
if tx.Nonce() != data.Nonce {
|
||||
|
|
@ -278,14 +221,14 @@ t.Run("TestContractCreationTx", func (t *testing.T) {
|
|||
if tx.GasPrice().Uint64() != data.GasPrice {
|
||||
t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String())
|
||||
}
|
||||
if block.GasLimit() != data.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit())
|
||||
if block1.GasLimit() != data.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block1.GasLimit())
|
||||
}
|
||||
if block.Hash().String() != data.BlockHash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String())
|
||||
if block3.Hash().String() != data.BlockHash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block1.Hash().String())
|
||||
}
|
||||
if block.Number().String() != data.BlockNumber {
|
||||
t.Fatalf("Block Number [%v]: Block number not found", block.Number().String())
|
||||
if block3.Number().String() != data.BlockNumber {
|
||||
t.Fatalf("Block Number [%v]: Block number not found", block1.Number().String())
|
||||
}
|
||||
if tx.Value().String() != data.Amount {
|
||||
t.Fatalf("Amount [%v]: Amount not found", tx.Value().String())
|
||||
|
|
@ -294,10 +237,10 @@ t.Run("TestContractCreationTx", func (t *testing.T) {
|
|||
t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String())
|
||||
}
|
||||
var status string
|
||||
if receipt2.Status == 1 {
|
||||
if receipt.Status == 1 {
|
||||
status = "SUCCESS"
|
||||
}
|
||||
if receipt2.Status == 0 {
|
||||
if receipt.Status == 0 {
|
||||
status = "FAIL"
|
||||
}
|
||||
if status != data.Status {
|
||||
|
|
@ -313,45 +256,9 @@ t.Run("TestContractCreationTx", func (t *testing.T) {
|
|||
t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract)
|
||||
}
|
||||
}
|
||||
ClearTables()
|
||||
})
|
||||
|
||||
t.Run("TestTransactionsToReturnTransactions", func(t *testing.T) {
|
||||
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
signer := types.NewEIP155Signer(big.NewInt(2147483647))
|
||||
|
||||
//Nonce, To Address,Value, GasLimit, Gasprice, data
|
||||
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx,_ := types.SignTx(tx1, signer, key)
|
||||
tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22})
|
||||
mytx2,_ := types.SignTx(tx2, signer, key)
|
||||
tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33})
|
||||
mytx3,_ := types.SignTx(tx3, signer, key)
|
||||
txs := []*types.Transaction{mytx, mytx2, mytx3}
|
||||
|
||||
receipt1 := &types.Receipt{
|
||||
Status: types.ReceiptStatusSuccessful,
|
||||
CumulativeGasUsed: 1,
|
||||
Logs: []*types.Log{
|
||||
{Address: common.BytesToAddress([]byte{0x11})},
|
||||
{Address: common.BytesToAddress([]byte{0x01, 0x11})},
|
||||
},
|
||||
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
|
||||
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
|
||||
GasUsed: 111111,
|
||||
}
|
||||
|
||||
receipts := []*types.Receipt{receipt1}
|
||||
block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts)
|
||||
|
||||
if err := core.SWriteBlock(block, receipts); err != nil {
|
||||
t.Fatalf("Failed to write block into database: %v", err)
|
||||
}
|
||||
sqldb, err := core.DBConnection()
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, tx := range txs {
|
||||
txn := core.SGetTransaction(sqldb, tx.Hash().String())
|
||||
byt := []byte(txn)
|
||||
|
|
@ -359,13 +266,13 @@ t.Run("TestTransactionsToReturnTransactions", func(t *testing.T) {
|
|||
json.Unmarshal(byt, &data)
|
||||
|
||||
//TODO age, data
|
||||
if tx.Hash().String() != data.TxHash {
|
||||
if strings.ToLower(tx.Hash().String()) != data.TxHash {
|
||||
t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String())
|
||||
}
|
||||
if tx.From().String() != data.From {
|
||||
if strings.ToLower(tx.From().String()) != data.From {
|
||||
t.Fatalf("From Addr [%v]: From addr not found", tx.From().String())
|
||||
}
|
||||
if tx.To().String() != data.ToGet {
|
||||
if strings.ToLower(tx.To().String()) != data.ToGet {
|
||||
t.Fatalf("To Addr [%v]: To addr not found", tx.To().String())
|
||||
}
|
||||
if tx.Nonce() != data.Nonce {
|
||||
|
|
@ -377,14 +284,14 @@ t.Run("TestTransactionsToReturnTransactions", func(t *testing.T) {
|
|||
if tx.GasPrice().Uint64() != data.GasPrice {
|
||||
t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String())
|
||||
}
|
||||
if block.GasLimit() != data.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit())
|
||||
if block1.GasLimit() != data.GasLimit {
|
||||
t.Fatalf("Gas Limit [%v]: Gas limit not found", block1.GasLimit())
|
||||
}
|
||||
if block.Hash().String() != data.BlockHash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String())
|
||||
if block1.Hash().String() != data.BlockHash {
|
||||
t.Fatalf("Block Hash [%v]: Block hash not found", block1.Hash().String())
|
||||
}
|
||||
if block.Number().String() != data.BlockNumber {
|
||||
t.Fatalf("Block Number [%v]: Block number not found", block.Number().String())
|
||||
if block1.Number().String() != data.BlockNumber {
|
||||
t.Fatalf("Block Number [%v]: Block number not found", block1.Number().String())
|
||||
}
|
||||
if tx.Value().String() != data.Amount {
|
||||
t.Fatalf("Amount [%v]: Amount not found", tx.Value().String())
|
||||
|
|
@ -393,10 +300,10 @@ t.Run("TestTransactionsToReturnTransactions", func(t *testing.T) {
|
|||
t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String())
|
||||
}
|
||||
var status string
|
||||
if receipt1.Status == 1 {
|
||||
if receipt.Status == 1 {
|
||||
status = "SUCCESS"
|
||||
}
|
||||
if receipt1.Status == 0 {
|
||||
if receipt.Status == 0 {
|
||||
status = "FAIL"
|
||||
}
|
||||
if status != data.Status {
|
||||
|
|
@ -412,104 +319,47 @@ t.Run("TestTransactionsToReturnTransactions", func(t *testing.T) {
|
|||
t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract)
|
||||
}
|
||||
}
|
||||
|
||||
if getAllTx := core.SGetAllTransactions(sqldb); len(getAllTx) == 0 {
|
||||
t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx)
|
||||
}
|
||||
ClearTables()
|
||||
})
|
||||
|
||||
t.Run("TestAccountsToReturnAccounts", func(t *testing.T) {
|
||||
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
signer := types.NewEIP155Signer(big.NewInt(2147483647))
|
||||
for _, tx := range txs {
|
||||
fmt.Println("test account", tx.To().String())
|
||||
accountAddrTo := core.SGetAccount(sqldb, tx.To().String())
|
||||
byts := []byte(accountAddrTo)
|
||||
var accountDataTo core.SAccounts
|
||||
json.Unmarshal(byts, &accountDataTo)
|
||||
|
||||
toAddr1 := common.BytesToAddress([]byte{0x11})
|
||||
toAddr2 := common.BytesToAddress([]byte{0x22})
|
||||
toAddr3 := common.BytesToAddress([]byte{0x33})
|
||||
|
||||
toAmount1 := big.NewInt(111)
|
||||
var toAmountPrev1 string = "3968686868"
|
||||
|
||||
sqldb, err := core.DBConnection()
|
||||
if (err != nil) {
|
||||
panic(err)
|
||||
if strings.ToLower(tx.To().String()) != accountDataTo.Addr {
|
||||
t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr)
|
||||
}
|
||||
|
||||
core.CreateAccount(sqldb, toAddr1.Hex(), toAmountPrev1, "1")
|
||||
core.CreateAccount(sqldb, toAddr2.Hex(), "423798729847", "1")
|
||||
core.CreateAccount(sqldb, toAddr3.Hex(), "0", "1")
|
||||
core.CreateAccount(sqldb, "0x71562b71999873DB5b286dF957af199Ec94617F7", "3968686868", "1")
|
||||
|
||||
//Nonce, To Address,Value, GasLimit, Gasprice, data
|
||||
tx1 := types.NewTransaction(1, toAddr1, toAmount1, 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
mytx,_ := types.SignTx(tx1, signer, key)
|
||||
tx2 := types.NewTransaction(2, toAddr2, big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22})
|
||||
mytx2,_ := types.SignTx(tx2, signer, key)
|
||||
tx3 := types.NewTransaction(3, toAddr3, big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33})
|
||||
mytx3,_ := types.SignTx(tx3, signer, key)
|
||||
txs := []*types.Transaction{mytx, mytx2, mytx3}
|
||||
|
||||
receipt1 := &types.Receipt{
|
||||
Status: types.ReceiptStatusSuccessful,
|
||||
CumulativeGasUsed: 1,
|
||||
Logs: []*types.Log{
|
||||
{Address: common.BytesToAddress([]byte{0x11})},
|
||||
{Address: common.BytesToAddress([]byte{0x01, 0x11})},
|
||||
},
|
||||
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
|
||||
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
|
||||
GasUsed: 111111,
|
||||
if tx.Value().String() != accountDataTo.Balance {
|
||||
t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance)
|
||||
}
|
||||
|
||||
receipts := []*types.Receipt{receipt1}
|
||||
block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts)
|
||||
if err := core.SWriteBlock(block, receipts); err != nil {
|
||||
t.Fatalf("Failed to write block into database: %v", err)
|
||||
if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.AccountNonce {
|
||||
t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.AccountNonce)
|
||||
}
|
||||
|
||||
if toAddr1.String() != tx1.To().String() {
|
||||
t.Fatalf("To address [%v]: To address not found", toAddr1.String())
|
||||
}
|
||||
accountAddrTo, _ := core.InnerSGetAccount(sqldb, toAddr1.String())
|
||||
//ewAccountNonceReceiver.Add(accountR, nonceIncrement)
|
||||
addedAmount := new(big.Int)
|
||||
toAmountPrevious1, _ := strconv.ParseUint(toAmountPrev1, 10, 64)
|
||||
b := new(big.Int).SetUint64(toAmountPrevious1)
|
||||
addedAmount.Add(toAmount1, b)
|
||||
toBalance := new(big.Int)
|
||||
toBalance, _ = toBalance.SetString(accountAddrTo.Balance, 10)
|
||||
accountAddrFrom := core.SGetAccount(sqldb, fromAddr)
|
||||
byts := []byte(accountAddrFrom)
|
||||
var accountDataFrom core.SAccounts
|
||||
json.Unmarshal(byts, &accountDataFrom)
|
||||
|
||||
if toBalance.Cmp(addedAmount) != 0 {
|
||||
t.Fatalf("To address balance [%v]: To address balance not correct FFO", toBalance)
|
||||
if fromAddr != accountDataFrom.Addr {
|
||||
t.Fatalf("To address [%v]: To address not found", accountDataFrom.Addr)
|
||||
}
|
||||
|
||||
//for _, tx := range txs {
|
||||
// accountAddrTo := core.SGetAccount(sqldb, tx.To().String())
|
||||
// byts := []byte(accountAddrTo)
|
||||
// var accountDataTo core.SAccounts
|
||||
// json.Unmarshal(byts, &accountDataTo)
|
||||
//
|
||||
// if tx.To().String() != accountDataTo.Addr {
|
||||
// t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr)
|
||||
// }
|
||||
// if tx.Value().String() != accountDataTo.Balance {
|
||||
// t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance)
|
||||
// }
|
||||
// if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.AccountNonce {
|
||||
// t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.AccountNonce)
|
||||
// }
|
||||
//}
|
||||
|
||||
if getAllAccountTxs := core.SGetAccountTxs(sqldb, toAddr1.String()); len(getAllAccountTxs) == 0 {
|
||||
if fromAddrEndBalance != accountDataFrom.Balance {
|
||||
t.Fatalf("To address balance [%v]: To address balance not found", accountDataFrom.Balance)
|
||||
}
|
||||
if fromAddrEndNonce != accountDataFrom.AccountNonce {
|
||||
t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataFrom.AccountNonce)
|
||||
}
|
||||
if getAllAccountTxs := core.SGetAccountTxs(sqldb, toAddr.String()); len(getAllAccountTxs) == 0 {
|
||||
t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs)
|
||||
}
|
||||
|
||||
if getAllAccounts := core.SGetAllAccounts(sqldb); len(getAllAccounts) == 0 {
|
||||
t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts)
|
||||
}
|
||||
ClearTables()
|
||||
})
|
||||
|
||||
ClearTables()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue