DERO HE Stargate Release 19
This commit is contained in:
parent
d32456d7ee
commit
76173abe4f
@ -184,6 +184,10 @@ func Blockchain_Start(params map[string]interface{}) (*Blockchain, error) {
|
|||||||
|
|
||||||
chain.Initialise_Chain_From_DB() // load the chain from the disk
|
chain.Initialise_Chain_From_DB() // load the chain from the disk
|
||||||
|
|
||||||
|
if chain.Pruned >= 1 {
|
||||||
|
logger.Info("Chain Pruned till", "topoheight", chain.Pruned)
|
||||||
|
}
|
||||||
|
|
||||||
metrics.Version = config.Version.String()
|
metrics.Version = config.Version.String()
|
||||||
go metrics.Dump_metrics_data_directly(logger, globals.Arguments["--node-tag"]) // enable metrics if someone needs them
|
go metrics.Dump_metrics_data_directly(logger, globals.Arguments["--node-tag"]) // enable metrics if someone needs them
|
||||||
|
|
||||||
@ -245,7 +249,7 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
|
|||||||
|
|
||||||
// safety so if anything wrong happens, verification fails
|
// safety so if anything wrong happens, verification fails
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while adding new block", "blid", block_hash, "stack", fmt.Sprintf("%s", string(debug.Stack())))
|
logger.V(1).Error(nil, "Recovered while adding new block", "blid", block_hash, "r", r, "stack", fmt.Sprintf("%s", string(debug.Stack())))
|
||||||
result = false
|
result = false
|
||||||
err = errormsg.ErrPanic
|
err = errormsg.ErrPanic
|
||||||
}
|
}
|
||||||
@ -257,7 +261,7 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
|
|||||||
func() {
|
func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while instrumenting", "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while instrumenting", "r", r, "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
metrics.Set.GetOrCreateCounter("blockchain_tx_total").Add(len(cbl.Bl.Tx_hashes))
|
metrics.Set.GetOrCreateCounter("blockchain_tx_total").Add(len(cbl.Bl.Tx_hashes))
|
||||||
@ -869,7 +873,7 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
|
|||||||
|
|
||||||
func() {
|
func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.Error(r.(error), "Mempool House Keeping triggered panic", "height", block_height)
|
logger.Error(nil, "Mempool House Keeping triggered panic", "r", r, "height", block_height)
|
||||||
}
|
}
|
||||||
|
|
||||||
purge_count := chain.MiniBlocks.PurgeHeight(chain.Get_Stable_Height()) // purge all miniblocks upto this height
|
purge_count := chain.MiniBlocks.PurgeHeight(chain.Get_Stable_Height()) // purge all miniblocks upto this height
|
||||||
@ -934,9 +938,6 @@ func (chain *Blockchain) Initialise_Chain_From_DB() {
|
|||||||
defer chain.Unlock()
|
defer chain.Unlock()
|
||||||
|
|
||||||
chain.Pruned = chain.LocatePruneTopo()
|
chain.Pruned = chain.LocatePruneTopo()
|
||||||
if chain.Pruned >= 1 {
|
|
||||||
logger.Info("Chain Pruned till", "topoheight", chain.Pruned)
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the tips from the chain , first by reaching top height
|
// find the tips from the chain , first by reaching top height
|
||||||
// then downgrading to top-10 height
|
// then downgrading to top-10 height
|
||||||
@ -992,11 +993,20 @@ func (chain *Blockchain) Get_Stable_Height() int64 {
|
|||||||
func (chain *Blockchain) Get_TIPS() (tips []crypto.Hash) {
|
func (chain *Blockchain) Get_TIPS() (tips []crypto.Hash) {
|
||||||
for _, x := range chain.Tips {
|
for _, x := range chain.Tips {
|
||||||
tips = append(tips, x)
|
tips = append(tips, x)
|
||||||
|
|
||||||
}
|
}
|
||||||
return tips
|
return tips
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check whether the block is a tip
|
||||||
|
func (chain *Blockchain) Is_Block_Tip(blid crypto.Hash) (result bool) {
|
||||||
|
for k := range chain.Tips {
|
||||||
|
if blid == k {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (chain *Blockchain) Get_Difficulty() uint64 {
|
func (chain *Blockchain) Get_Difficulty() uint64 {
|
||||||
return chain.Get_Difficulty_At_Tips(chain.Get_TIPS()).Uint64()
|
return chain.Get_Difficulty_At_Tips(chain.Get_TIPS()).Uint64()
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ func (chain *Blockchain) Accept_new_block(tstamp uint64, miniblock_blob []byte)
|
|||||||
// safety so if anything wrong happens, verification fails
|
// safety so if anything wrong happens, verification fails
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while accepting new block", "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while accepting new block", "r", r, "stack", debug.Stack())
|
||||||
err = fmt.Errorf("Error while parsing block")
|
err = fmt.Errorf("Error while parsing block")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -115,7 +115,7 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_versi
|
|||||||
var tx_hash crypto.Hash
|
var tx_hash crypto.Hash
|
||||||
defer func() { // safety so if anything wrong happens, verification fails
|
defer func() { // safety so if anything wrong happens, verification fails
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while verifying tx", "txid", tx_hash, "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while verifying tx", "txid", tx_hash, "r", r, "stack", debug.Stack())
|
||||||
err = fmt.Errorf("Stack Trace %s", debug.Stack())
|
err = fmt.Errorf("Stack Trace %s", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -277,7 +277,7 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase(hf_version int64, tx *tr
|
|||||||
var tx_hash crypto.Hash
|
var tx_hash crypto.Hash
|
||||||
defer func() { // safety so if anything wrong happens, verification fails
|
defer func() { // safety so if anything wrong happens, verification fails
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while verifying tx", "txid", tx_hash, "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while verifying tx", "txid", tx_hash, "r", r, "stack", debug.Stack())
|
||||||
err = fmt.Errorf("Stack Trace %s", debug.Stack())
|
err = fmt.Errorf("Stack Trace %s", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -42,6 +42,10 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
result.VariableStringKeys = map[string]interface{}{}
|
||||||
|
result.VariableUint64Keys = map[uint64]interface{}{}
|
||||||
|
result.Balances = map[string]uint64{}
|
||||||
|
|
||||||
scid := crypto.HashHexToHash(p.SCID)
|
scid := crypto.HashHexToHash(p.SCID)
|
||||||
|
|
||||||
topoheight := chain.Load_TOPO_HEIGHT()
|
topoheight := chain.Load_TOPO_HEIGHT()
|
||||||
@ -71,7 +75,9 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if sc_data_tree, err := ss.GetTree(string(scid[:])); err == nil {
|
var sc_data_tree *graviton.Tree
|
||||||
|
sc_data_tree, err = ss.GetTree(string(scid[:]))
|
||||||
|
if err == nil {
|
||||||
var zerohash crypto.Hash
|
var zerohash crypto.Hash
|
||||||
if balance_bytes, err := sc_data_tree.Get(zerohash[:]); err == nil {
|
if balance_bytes, err := sc_data_tree.Get(zerohash[:]); err == nil {
|
||||||
if len(balance_bytes) == 8 {
|
if len(balance_bytes) == 8 {
|
||||||
@ -89,6 +95,37 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if p.Variables { // user requested all variables
|
||||||
|
cursor := sc_data_tree.Cursor()
|
||||||
|
var k, v []byte
|
||||||
|
for k, v, err = cursor.First(); err == nil; k, v, err = cursor.Next() {
|
||||||
|
var vark, varv dvm.Variable
|
||||||
|
|
||||||
|
if nil == vark.UnmarshalBinary(k) && nil == varv.UnmarshalBinary(v) {
|
||||||
|
switch vark.Type {
|
||||||
|
case dvm.Uint64:
|
||||||
|
if varv.Type == dvm.Uint64 {
|
||||||
|
result.VariableUint64Keys[vark.ValueUint64] = varv.ValueUint64
|
||||||
|
} else {
|
||||||
|
result.VariableUint64Keys[vark.ValueUint64] = fmt.Sprintf("%x", []byte(varv.ValueString))
|
||||||
|
}
|
||||||
|
|
||||||
|
case dvm.String:
|
||||||
|
if varv.Type == dvm.Uint64 {
|
||||||
|
result.VariableStringKeys[vark.ValueString] = varv.ValueUint64
|
||||||
|
} else {
|
||||||
|
result.VariableStringKeys[vark.ValueString] = fmt.Sprintf("%x", []byte(varv.ValueString))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("UNKNOWN Data type")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if len(k) == 32 && len(v) == 8 { // it's SC balance
|
||||||
|
result.Balances[fmt.Sprintf("%x", k)] = binary.BigEndian.Uint64(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// give any uint64 keys data if any
|
// give any uint64 keys data if any
|
||||||
for _, value := range p.KeysUint64 {
|
for _, value := range p.KeysUint64 {
|
||||||
@ -108,7 +145,7 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
case dvm.Uint64:
|
case dvm.Uint64:
|
||||||
result.ValuesUint64 = append(result.ValuesUint64, fmt.Sprintf("%d", v.ValueUint64))
|
result.ValuesUint64 = append(result.ValuesUint64, fmt.Sprintf("%d", v.ValueUint64))
|
||||||
case dvm.String:
|
case dvm.String:
|
||||||
result.ValuesUint64 = append(result.ValuesUint64, fmt.Sprintf("%s", v.ValueString))
|
result.ValuesUint64 = append(result.ValuesUint64, fmt.Sprintf("%x", []byte(v.ValueString)))
|
||||||
default:
|
default:
|
||||||
result.ValuesUint64 = append(result.ValuesUint64, "UNKNOWN Data type")
|
result.ValuesUint64 = append(result.ValuesUint64, "UNKNOWN Data type")
|
||||||
}
|
}
|
||||||
@ -131,7 +168,7 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
case dvm.Uint64:
|
case dvm.Uint64:
|
||||||
result.ValuesString = append(result.ValuesUint64, fmt.Sprintf("%d", v.ValueUint64))
|
result.ValuesString = append(result.ValuesUint64, fmt.Sprintf("%d", v.ValueUint64))
|
||||||
case dvm.String:
|
case dvm.String:
|
||||||
result.ValuesString = append(result.ValuesString, fmt.Sprintf("%s", v.ValueString))
|
result.ValuesString = append(result.ValuesString, fmt.Sprintf("%x", []byte(v.ValueString)))
|
||||||
default:
|
default:
|
||||||
result.ValuesString = append(result.ValuesString, "UNKNOWN Data type")
|
result.ValuesString = append(result.ValuesString, "UNKNOWN Data type")
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ func ws_handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// safety so if anything wrong happens, verification fails
|
// safety so if anything wrong happens, verification fails
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while processing websocket request", "stack", debug.Stack())
|
logger.V(2).Error(nil, "Recovered while processing websocket request", "r", r, "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
if ws_server != nil {
|
if ws_server != nil {
|
||||||
client_connections.Delete(ws_server)
|
client_connections.Delete(ws_server)
|
||||||
|
@ -85,7 +85,7 @@ func (d *socks_dialer) DialContext(ctx context.Context, network, address string)
|
|||||||
func dial_random_read_response(in []byte) (out []byte, err error) {
|
func dial_random_read_response(in []byte) (out []byte, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while checking updates", "stack", debug.Stack())
|
logger.V(2).Error(nil, "Recovered while checking updates", "r", r, "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ func check_update() {
|
|||||||
// add panic handler, in case DNS acts rogue and tries to attack
|
// add panic handler, in case DNS acts rogue and tries to attack
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(2).Error(r.(error), "Recovered while checking updates", "stack", debug.Stack())
|
logger.V(2).Error(nil, "Recovered while checking updates", r, "r", "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -270,6 +270,8 @@ type txinfo struct {
|
|||||||
SC_Keys map[string]string // SC key value of
|
SC_Keys map[string]string // SC key value of
|
||||||
SC_Args rpc.Arguments // rpc.Arguments
|
SC_Args rpc.Arguments // rpc.Arguments
|
||||||
SC_Code string // install SC
|
SC_Code string // install SC
|
||||||
|
SC_State rpc.GetSC_Result // current SC state
|
||||||
|
SC_Install bool
|
||||||
|
|
||||||
Assets []Asset
|
Assets []Asset
|
||||||
}
|
}
|
||||||
@ -576,6 +578,22 @@ func load_tx_from_rpc(info *txinfo, txhash string) (err error) {
|
|||||||
info.SC_Balance = tx_result.Txs[0].Balance
|
info.SC_Balance = tx_result.Txs[0].Balance
|
||||||
info.SC_Balance_string = fmt.Sprintf("%.05f", float64(uint64(info.SC_Balance)/100000))
|
info.SC_Balance_string = fmt.Sprintf("%.05f", float64(uint64(info.SC_Balance)/100000))
|
||||||
info.SC_Code = tx_result.Txs[0].Code
|
info.SC_Code = tx_result.Txs[0].Code
|
||||||
|
|
||||||
|
if tx.TransactionType == transaction.SC_TX && len(info.SC_Code) >= 1 {
|
||||||
|
|
||||||
|
if len(info.SC_Code) >= 1 {
|
||||||
|
info.SC_Install = true
|
||||||
|
}
|
||||||
|
var p = rpc.GetSC_Params{SCID: txhash, Variables: true}
|
||||||
|
var r rpc.GetSC_Result
|
||||||
|
|
||||||
|
if err = rpc_client.Call("DERO.GetSC", p, &r); err != nil {
|
||||||
|
return fmt.Errorf("gettransa rpc failed err %s", err)
|
||||||
|
} else {
|
||||||
|
info.SC_State = r
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//info.Ring = strings.Join(info.OutAddress, " ")
|
//info.Ring = strings.Join(info.OutAddress, " ")
|
||||||
|
|
||||||
//fmt.Printf("tx_result %+v\n",tx_result.Txs)
|
//fmt.Printf("tx_result %+v\n",tx_result.Txs)
|
||||||
|
@ -31,16 +31,54 @@
|
|||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
||||||
|
{{if .info.SC_Install }}
|
||||||
|
|
||||||
|
<div class="center" style="border: 1px;width: 100%;overflow: hidden; text-overflow: ellipsis;">
|
||||||
|
<H5 style="margin:5px">SCID current reserves </H5>
|
||||||
|
|
||||||
|
<table class="center" style="width: 80%; margin-top:10px;border: 1px">
|
||||||
|
<tr>
|
||||||
|
<td>SCID</td> <td style="width: 20%">Amount(in atomic units)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{{range $k, $v := .info.SC_State.Balances}}
|
||||||
|
<tr>
|
||||||
|
<td>{{ $k }}</td> <td> {{ $v }} </td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<H5 style="margin:5px">SCID string variables </H5>
|
||||||
|
<table class="center" style="border: 1px;width: 80%; margin-top:10px;overflow: hidden; text-overflow: ellipsis;">
|
||||||
|
<tr>
|
||||||
|
<td>key</td> <td style="width: 20%;text-align:left">value</td>
|
||||||
|
</tr>
|
||||||
|
{{range $k, $v := .info.SC_State.VariableStringKeys}}
|
||||||
|
<tr>
|
||||||
|
<td>{{ $k }}</td> <td style="width: 20%;text-align:left;overflow: hidden; text-overflow: ellipsis;"> {{ $v }} </td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</table>
|
||||||
|
<H5 style="margin:5px">SCID uint64 variables </H5>
|
||||||
|
<table class="center" style="border: 1px;width: 80%; margin-top:10px">
|
||||||
|
<tr>
|
||||||
|
<td>key</td> <td style="width: 20%;text-align:left">value</td>
|
||||||
|
</tr>
|
||||||
|
{{range $k, $v := .info.SC_State.VariableUint64Keys}}
|
||||||
|
<tr>
|
||||||
|
<td>{{ $k }}</td> <td style="width: 20%;text-align:left;overflow: hidden; text-overflow: ellipsis;"> {{ $v }} </td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if or (eq .info.TransactionType "NORMAL") (eq .info.TransactionType "BURN") (eq .info.TransactionType "SC") }}
|
{{if or (eq .info.TransactionType "NORMAL") (eq .info.TransactionType "BURN") (eq .info.TransactionType "SC") }}
|
||||||
|
|
||||||
<H5 style="margin:5px">Tx RootHash: {{.info.RootHash}} built height : {{.info.HeightBuilt}} </H5>
|
<H5 style="margin:5px">Tx RootHash: {{.info.RootHash}} built height : {{.info.HeightBuilt}} </H5>
|
||||||
|
|
||||||
{{if .info.PayID32}}
|
|
||||||
<H5 style="margin:5px">PaymentID: {{.info.PayID32}}</H5>
|
|
||||||
{{end}}
|
|
||||||
{{if .info.PayID8}}
|
|
||||||
<H5 style="margin:5px">Encrypted PaymentID: {{.info.PayID8}}</H5>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
<table class="center" style="width: 80%; margin-top:10px">
|
<table class="center" style="width: 80%; margin-top:10px">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -20,4 +20,4 @@ import "github.com/blang/semver/v4"
|
|||||||
|
|
||||||
// right now it has to be manually changed
|
// right now it has to be manually changed
|
||||||
// do we need to include git commitsha??
|
// do we need to include git commitsha??
|
||||||
var Version = semver.MustParse("3.4.46-1.DEROHE.STARGATE+08112021")
|
var Version = semver.MustParse("3.4.49-1.DEROHE.STARGATE+09112021")
|
||||||
|
@ -153,29 +153,13 @@ try_again:
|
|||||||
|
|
||||||
func (connection *Connection) process_object_response(response Objects, sent int64, syncing bool) error {
|
func (connection *Connection) process_object_response(response Objects, sent int64, syncing bool) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// make sure connection does not timeout and be killed while processing huge blocks
|
|
||||||
processing_complete := make(chan bool)
|
|
||||||
go func() {
|
|
||||||
ticker := time.NewTicker(500 * time.Millisecond)
|
|
||||||
defer ticker.Stop()
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-processing_complete:
|
|
||||||
return // complete the loop
|
|
||||||
case <-ticker.C: // give the chain some more time to respond
|
|
||||||
atomic.StoreInt64(&connection.LastObjectRequestTime, time.Now().Unix())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
processing_complete <- true
|
|
||||||
}()
|
|
||||||
|
|
||||||
defer globals.Recover(2)
|
defer globals.Recover(2)
|
||||||
|
|
||||||
for i := 0; i < len(response.CBlocks); i++ { // process incoming full blocks
|
for i := 0; i < len(response.CBlocks); i++ { // process incoming full blocks
|
||||||
|
// make sure connection does not timeout and be killed while processing huge blocks
|
||||||
|
|
||||||
|
atomic.StoreInt64(&connection.LastObjectRequestTime, time.Now().Unix())
|
||||||
|
|
||||||
var cbl block.Complete_Block // parse incoming block and deserialize it
|
var cbl block.Complete_Block // parse incoming block and deserialize it
|
||||||
var bl block.Block
|
var bl block.Block
|
||||||
// lets deserialize block first and see whether it is the requested object
|
// lets deserialize block first and see whether it is the requested object
|
||||||
@ -190,6 +174,10 @@ func (connection *Connection) process_object_response(response Objects, sent int
|
|||||||
// give the chain some more time to respond
|
// give the chain some more time to respond
|
||||||
atomic.StoreInt64(&connection.LastObjectRequestTime, time.Now().Unix())
|
atomic.StoreInt64(&connection.LastObjectRequestTime, time.Now().Unix())
|
||||||
|
|
||||||
|
// do not try to add blocks too much into future
|
||||||
|
if syncing && int64(bl.Height) > chain.Get_Height()+4 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// check whether the object was requested one
|
// check whether the object was requested one
|
||||||
|
|
||||||
// complete the txs
|
// complete the txs
|
||||||
|
@ -734,7 +734,7 @@ func broadcast_Tx(tx *transaction.Transaction, PeerID uint64, sent int64) (relay
|
|||||||
go func(connection *Connection) {
|
go func(connection *Connection) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
connection.logger.V(1).Error(r.(error), "Recovere3d while sending tx", "stack", debug.Stack())
|
connection.logger.V(1).Error(nil, "Recovere3d while sending tx", "r", r, "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -219,11 +219,7 @@ func P2P_engine() {
|
|||||||
// will block until the connection dies or is killed
|
// will block until the connection dies or is killed
|
||||||
func connect_with_endpoint(endpoint string, sync_node bool) {
|
func connect_with_endpoint(endpoint string, sync_node bool) {
|
||||||
|
|
||||||
defer func() {
|
defer globals.Recover(2)
|
||||||
if r := recover(); r != nil {
|
|
||||||
logger.V(2).Error(r.(error), "Recovered while connecting", "stack", fmt.Sprintf("%s", string(debug.Stack())))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
remote_ip, err := net.ResolveTCPAddr("tcp", endpoint)
|
remote_ip, err := net.ResolveTCPAddr("tcp", endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -415,7 +411,7 @@ func P2P_Server_v2() {
|
|||||||
|
|
||||||
func handle_connection_panic(c *Connection) {
|
func handle_connection_panic(c *Connection) {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while handling connection", "stack", debug.Stack())
|
logger.V(2).Error(nil, "Recovered while handling connection", "r", r, "stack", debug.Stack())
|
||||||
c.exit()
|
c.exit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -442,10 +438,9 @@ func process_connection(conn net.Conn, remote_addr *net.TCPAddr, incoming, sync_
|
|||||||
c.logger = logger.WithName("outgoing").WithName(remote_addr.String())
|
c.logger = logger.WithName("outgoing").WithName(remote_addr.String())
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
//defer globals.Recover()
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while handling connection", "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while handling connection", "r", r, "stack", debug.Stack())
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -307,7 +307,7 @@ func (c *Connection) processChunkedBlock(request Objects, isnotified bool, wasch
|
|||||||
}
|
}
|
||||||
|
|
||||||
// object is already is in our chain, we need not relay it
|
// object is already is in our chain, we need not relay it
|
||||||
if chain.Is_Block_Topological_order(blid) {
|
if chain.Is_Block_Topological_order(blid) || chain.Is_Block_Tip(blid) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,24 +396,7 @@ func (c *Connection) processChunkedBlock(request Objects, isnotified bool, wasch
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure connection does not timeout and be killed while processing huge blocks
|
// make sure connection does not timeout and be killed while processing huge blocks
|
||||||
processing_complete := make(chan bool)
|
|
||||||
go func() {
|
|
||||||
ticker := time.NewTicker(500 * time.Millisecond)
|
|
||||||
defer ticker.Stop()
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-processing_complete:
|
|
||||||
return // complete the loop
|
|
||||||
case <-ticker.C: // give the chain some more time to respond
|
|
||||||
atomic.StoreInt64(&c.LastObjectRequestTime, time.Now().Unix())
|
atomic.StoreInt64(&c.LastObjectRequestTime, time.Now().Unix())
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
processing_complete <- true
|
|
||||||
}()
|
|
||||||
|
|
||||||
// check if we can add ourselves to chain
|
// check if we can add ourselves to chain
|
||||||
if err, ok := chain.Add_Complete_Block(&cbl); ok { // if block addition was successfil
|
if err, ok := chain.Add_Complete_Block(&cbl); ok { // if block addition was successfil
|
||||||
// notify all peers
|
// notify all peers
|
||||||
|
@ -226,6 +226,7 @@ type (
|
|||||||
GetSC_Params struct {
|
GetSC_Params struct {
|
||||||
SCID string `json:"scid"`
|
SCID string `json:"scid"`
|
||||||
Code bool `json:"code,omitempty"` // if true code will be returned
|
Code bool `json:"code,omitempty"` // if true code will be returned
|
||||||
|
Variables bool `json:"variables,omitempty"` // if true all SC variables will be returned
|
||||||
TopoHeight int64 `json:"topoheight,omitempty"` // all queries are related to this topoheight
|
TopoHeight int64 `json:"topoheight,omitempty"` // all queries are related to this topoheight
|
||||||
KeysUint64 []uint64 `json:"keysuint64,omitempty"`
|
KeysUint64 []uint64 `json:"keysuint64,omitempty"`
|
||||||
KeysString []string `json:"keysstring,omitempty"`
|
KeysString []string `json:"keysstring,omitempty"`
|
||||||
@ -235,6 +236,9 @@ type (
|
|||||||
ValuesUint64 []string `json:"valuesuint64,omitempty"`
|
ValuesUint64 []string `json:"valuesuint64,omitempty"`
|
||||||
ValuesString []string `json:"valuesstring,omitempty"`
|
ValuesString []string `json:"valuesstring,omitempty"`
|
||||||
ValuesBytes []string `json:"valuesbytes,omitempty"`
|
ValuesBytes []string `json:"valuesbytes,omitempty"`
|
||||||
|
VariableStringKeys map[string]interface{} `json:"stringkeys,omitempty"`
|
||||||
|
VariableUint64Keys map[uint64]interface{} `json:"uint64keys,omitempty"`
|
||||||
|
Balances map[string]uint64 `json:"balances,omitempty"`
|
||||||
Balance uint64 `json:"balance"`
|
Balance uint64 `json:"balance"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
@ -282,7 +282,7 @@ func (w *Wallet_Memory) DecodeEncryptedBalanceNow(el *crypto.ElGamal) uint64 {
|
|||||||
func (w *Wallet_Memory) GetSelfEncryptedBalanceAtTopoHeight(scid crypto.Hash, topoheight int64) (r rpc.GetEncryptedBalance_Result, err error) {
|
func (w *Wallet_Memory) GetSelfEncryptedBalanceAtTopoHeight(scid crypto.Hash, topoheight int64) (r rpc.GetEncryptedBalance_Result, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while connecting", "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while connecting", "r", r, "stack", debug.Stack())
|
||||||
err = fmt.Errorf("Recovered while connecting", "stack", debug.Stack())
|
err = fmt.Errorf("Recovered while connecting", "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -301,7 +301,7 @@ func (w *Wallet_Memory) GetEncryptedBalanceAtTopoHeight(scid crypto.Hash, topohe
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
logger.V(1).Error(r.(error), "Recovered while connecting", "stack", debug.Stack())
|
logger.V(1).Error(nil, "Recovered while connecting", "r", r, "stack", debug.Stack())
|
||||||
err = fmt.Errorf("Recovered while connecting", "stack", debug.Stack())
|
err = fmt.Errorf("Recovered while connecting", "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -437,6 +437,12 @@ func (w *Wallet_Memory) Random_ring_members(scid crypto.Hash) (alist []string) {
|
|||||||
|
|
||||||
// sync history of wallet from blockchain
|
// sync history of wallet from blockchain
|
||||||
func (w *Wallet_Memory) SyncHistory(scid crypto.Hash) (balance uint64) {
|
func (w *Wallet_Memory) SyncHistory(scid crypto.Hash) (balance uint64) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
logger.V(1).Error(nil, "Recovered while syncing connecting", "r", r, "stack", debug.Stack())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if w.getEncryptedBalanceresult(scid).Registration < 0 { // unregistered so skip
|
if w.getEncryptedBalanceresult(scid).Registration < 0 { // unregistered so skip
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -707,6 +713,11 @@ func (w *Wallet_Memory) synchistory_block(scid crypto.Hash, topo int64) (err err
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if daemon was syncing/or disk corrupption, it may not give data, so skip
|
||||||
|
if len(tx_result.Txs) == 0 {
|
||||||
|
return fmt.Errorf("Daemon did not expandd tx %s", bl.Tx_hashes[i].String())
|
||||||
|
}
|
||||||
|
|
||||||
// since balance might change with tx, we track within tx using this
|
// since balance might change with tx, we track within tx using this
|
||||||
previous_balance_e_tx := new(crypto.ElGamal).Deserialize(previous_balance_e.Serialize())
|
previous_balance_e_tx := new(crypto.ElGamal).Deserialize(previous_balance_e.Serialize())
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func (rpcserver *RPCServer) Run(wallet *walletapi.Wallet_Disk) {
|
|||||||
var ws_server *jrpc2.Server
|
var ws_server *jrpc2.Server
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil { // safety so if anything wrong happens, verification fails
|
if r := recover(); r != nil { // safety so if anything wrong happens, verification fails
|
||||||
rpcserver.logger.V(1).Error(r.(error), "Recovered while processing websocket request", "stack", debug.Stack())
|
rpcserver.logger.V(1).Error(nil, "Recovered while processing websocket request", "r", r, "stack", debug.Stack())
|
||||||
}
|
}
|
||||||
if ws_server != nil {
|
if ws_server != nil {
|
||||||
client_connections.Delete(ws_server)
|
client_connections.Delete(ws_server)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user