changed start script for web socket access, modified writeBlock

This commit is contained in:
Dustin Brickwood 2018-05-02 15:14:59 -04:00
parent bd6acd8059
commit 1d93088980
4 changed files with 91 additions and 75 deletions

View file

@ -8,7 +8,7 @@ import (
_ "github.com/lib/pq"
shyftdb "github.com/ethereum/go-ethereum/shyftdb"
"github.com/ethereum/go-ethereum/shyftdb"
"github.com/gorilla/mux"
)
@ -48,6 +48,7 @@ func GetAllTransactions(w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)

View file

@ -94,8 +94,9 @@ func WriteBlock(sqldb *sql.DB, block *types.Block) error {
panic(qerr)
}
if block.Transactions().Len() > 0 {
if block.Transactions().Len() > 0 && block.Transactions()[0].To() != nil {
for _, tx := range block.Transactions() {
//WriteMinerRewards(sqldb, block)
WriteTransactions(sqldb, tx, block.Header().Hash())
WriteFromBalance(sqldb, tx)
}
@ -233,6 +234,20 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s
return sendAndReceiveData, balanceReceiver, balanceSender
}
//func WriteMinerRewards(sqldb *sql.DB, block *types.Block) {
// var totalGas big.Int
// //var txs []string
//
// fmt.Println("this is BLOCK.UNCLE", block.Uncles())
// fmt.Println("this is BLOCK UNCLE HASH", block.UncleHash().String())
// fmt.Println("this is BLOCK.TRANSACTIONS", block.Transactions())
// fmt.Println("this is BLOCK TOTAL GAS", block.GasUsed())
//
// for _, tx := range block.Transactions() {
// totalGas.Add(&totalGas, new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())))
// }
//}
// @NOTE: This function is extremely complex and requires heavy testing and knowdlege of edge cases:
// uncle blocks, account balance updates based on reorgs, diverges that get dropped.
// Reason for this is because the accounts are not deterministic like the block and tx hashes.
@ -246,7 +261,7 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s
// for _, tx := range block.Transactions() {
// totalGas.Add(totalGas, new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())))
// }
// retrievedData, err := db.Get(key, nil)
//// retrievedData, err := db.Get(key, nil)
// if err != nil {
// // Assume time this account has had a tx
// // Balacne is exclusively minerreward + total gas from the block b/c no prior evm activity
@ -477,7 +492,7 @@ func GetAllAccounts(sqldb *sql.DB) string {
}
defer accs.Close()
////
for accs.Next() {
var addr string
var balance string

View file

@ -2,28 +2,28 @@ var firstAccount = web3.eth.accounts[0]
var secondAccount = web3.eth.accounts[1]
var thirdAccount = web3.eth.accounts[2]
for (var i = 0; i < 10; i++) {
for (var i = 0; i < 1; i++) {
console.log('\t\t' + (i + 1) + ' - Transactions')
web3.eth.sendTransaction({
from: web3.eth.accounts[2],
to: web3.eth.accounts[0],
from: web3.eth.accounts[1],
to: web3.eth.accounts[2],
value: 5,
gas: 50000,
gasPrice: 20
});
web3.eth.sendTransaction({
from: web3.eth.accounts[1],
to: web3.eth.accounts[2],
value: 291,
gas: 50000,
gasPrice: 20
});
web3.eth.sendTransaction({
from: web3.eth.accounts[0],
to: web3.eth.accounts[1],
value: 53039,
gas: 50000,
gasPrice: 20
});
// web3.eth.sendTransaction({
// from: web3.eth.accounts[1],
// to: web3.eth.accounts[2],
// value: 291,
// gas: 50000,
// gasPrice: 20
// });
//
// web3.eth.sendTransaction({
// from: web3.eth.accounts[0],
// to: web3.eth.accounts[1],
// value: 53039,
// gas: 50000,
// gasPrice: 20
// });
}

View file

@ -1,2 +1,2 @@
#!/bin/sh
./build/bin/geth --config config.toml --nat=none --mine --minerthreads 4 --targetgaslimit 80000000 --unlock "0x43EC6d0942f7fAeF069F7F63D0384a27f529B062,0x9e602164C5826ebb5A6B68E4AFD9Cd466043dc4A,0x5Bd738164C61FB50eb12E227846CbaeF2dE965Aa,0xC04eE4131895F1d0C294D508AF65D94060AA42BB,0x07D899C4aC0c1725C35C5f816e60273B33a964F7" --password ./unlockPasswords.txt
./build/bin/geth --config config.toml --ws --wsaddr="0.0.0.0" --wsorigins "*" --nat=none --mine --minerthreads 4 --targetgaslimit 80000000 --unlock "0x43EC6d0942f7fAeF069F7F63D0384a27f529B062,0x9e602164C5826ebb5A6B68E4AFD9Cd466043dc4A,0x5Bd738164C61FB50eb12E227846CbaeF2dE965Aa,0xC04eE4131895F1d0C294D508AF65D94060AA42BB,0x07D899C4aC0c1725C35C5f816e60273B33a964F7" --password ./unlockPasswords.txt