mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
all: make nodes publish coinbase address to stats server (#1967)
* allow customizable stats server parameters * pass coinbase address to stats server
This commit is contained in:
parent
bfc69a09d7
commit
5340ce712c
4 changed files with 97 additions and 24 deletions
|
|
@ -73,7 +73,7 @@ fi
|
||||||
sync_mode=full
|
sync_mode=full
|
||||||
if test -z "$SYNC_MODE"
|
if test -z "$SYNC_MODE"
|
||||||
then
|
then
|
||||||
echo "SYNC_MODE not set, default to full" #full or fast
|
echo "SYNC_MODE not set, default to $sync_mode" #full or fast
|
||||||
else
|
else
|
||||||
echo "SYNC_MODE found, set to $SYNC_MODE"
|
echo "SYNC_MODE found, set to $SYNC_MODE"
|
||||||
sync_mode=$SYNC_MODE
|
sync_mode=$SYNC_MODE
|
||||||
|
|
@ -82,14 +82,33 @@ fi
|
||||||
gc_mode=archive
|
gc_mode=archive
|
||||||
if test -z "$GC_MODE"
|
if test -z "$GC_MODE"
|
||||||
then
|
then
|
||||||
echo "GC_MODE not set, default to archive" #full or archive
|
echo "GC_MODE not set, default to $gc_mode" #full or archive
|
||||||
else
|
else
|
||||||
echo "GC_MODE found, set to $GC_MODE"
|
echo "GC_MODE found, set to $GC_MODE"
|
||||||
gc_mode=$GC_MODE
|
gc_mode=$GC_MODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ethstats_address=localhost:2000
|
||||||
|
if test -z "$STATS_ADDRESS"
|
||||||
|
then
|
||||||
|
echo "STATS_ADDRESS not set, default to $ethstats_address"
|
||||||
|
else
|
||||||
|
echo "STATS_ADDRESS found, set to $STATS_ADDRESS"
|
||||||
|
ethstats_address=$STATS_ADDRESS
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Running a node with wallet: ${wallet} at IP: ${instance_ip}"
|
ethstats_secret=xinfin_xdpos_hybrid_local_stats
|
||||||
|
if test -z "$STATS_SECRET"
|
||||||
|
then
|
||||||
|
echo "STATS_SECRET not set, default to $ethstats_secret"
|
||||||
|
else
|
||||||
|
echo "STATS_SECRET found, set to $STATS_SECRET"
|
||||||
|
ethstats_secret=$STATS_SECRET
|
||||||
|
fi
|
||||||
|
|
||||||
|
netstats="${NODE_NAME}-${wallet}:$ethstats_secret@$ethstats_address"
|
||||||
|
|
||||||
|
echo "Running a node with wallet: ${wallet}"
|
||||||
echo "Starting nodes with $bootnodes ..."
|
echo "Starting nodes with $bootnodes ..."
|
||||||
|
|
||||||
# Note: --gcmode=archive means node will store all historical data. This will lead to high memory usage. But sync mode require archive to sync
|
# Note: --gcmode=archive means node will store all historical data. This will lead to high memory usage. But sync mode require archive to sync
|
||||||
|
|
@ -97,6 +116,7 @@ echo "Starting nodes with $bootnodes ..."
|
||||||
|
|
||||||
XDC \
|
XDC \
|
||||||
--gcmode ${gc_mode} --syncmode ${sync_mode} \
|
--gcmode ${gc_mode} --syncmode ${sync_mode} \
|
||||||
|
--ethstats ${netstats} \
|
||||||
--nat extip:${instance_ip} \
|
--nat extip:${instance_ip} \
|
||||||
--bootnodes ${bootnodes} \
|
--bootnodes ${bootnodes} \
|
||||||
--datadir /work/xdcchain \
|
--datadir /work/xdcchain \
|
||||||
|
|
|
||||||
|
|
@ -61,22 +61,41 @@ fi
|
||||||
|
|
||||||
sync_mode=full
|
sync_mode=full
|
||||||
if test -z "$SYNC_MODE"; then
|
if test -z "$SYNC_MODE"; then
|
||||||
echo "SYNC_MODE not set, default to full" #full or fast
|
echo "SYNC_MODE not set, default to $sync_mode" #full or fast
|
||||||
else
|
else
|
||||||
echo "SYNC_MODE found, set to $SYNC_MODE"
|
echo "SYNC_MODE found, set to $SYNC_MODE"
|
||||||
sync_mode=$SYNC_MODE
|
sync_mode=$SYNC_MODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gc_mode=archive
|
gc_mode=full
|
||||||
if test -z "$GC_MODE"; then
|
if test -z "$GC_MODE"; then
|
||||||
echo "GC_MODE not set, default to archive" #full or archive
|
echo "GC_MODE not set, default to $gc_mode" #full or archive
|
||||||
else
|
else
|
||||||
echo "GC_MODE found, set to $GC_MODE"
|
echo "GC_MODE found, set to $GC_MODE"
|
||||||
gc_mode=$GC_MODE
|
gc_mode=$GC_MODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ethstats_address=stats.xinfin.network:3000
|
||||||
|
if test -z "$STATS_ADDRESS"
|
||||||
|
then
|
||||||
|
echo "STATS_ADDRESS not set, default to $ethstats_address"
|
||||||
|
else
|
||||||
|
echo "STATS_ADDRESS found, set to $STATS_ADDRESS"
|
||||||
|
ethstats_address=$STATS_ADDRESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
ethstats_secret=xinfin_xdpos_hybrid_network_stats
|
||||||
|
if test -z "$STATS_SECRET"
|
||||||
|
then
|
||||||
|
echo "STATS_SECRET not set, default to $ethstats_secret"
|
||||||
|
else
|
||||||
|
echo "STATS_SECRET found, set to $STATS_SECRET"
|
||||||
|
ethstats_secret=$STATS_SECRET
|
||||||
|
fi
|
||||||
|
|
||||||
|
netstats="${NODE_NAME}-${wallet}:$ethstats_secret@$ethstats_address"
|
||||||
|
|
||||||
INSTANCE_IP=$(curl https://checkip.amazonaws.com)
|
INSTANCE_IP=$(curl https://checkip.amazonaws.com)
|
||||||
netstats="${NODE_NAME}-${wallet}-${INSTANCE_IP}:xinfin_xdpos_hybrid_network_stats@stats.xinfin.network:3000"
|
|
||||||
|
|
||||||
echo "Running a node with wallet: ${wallet} at IP: ${INSTANCE_IP}"
|
echo "Running a node with wallet: ${wallet} at IP: ${INSTANCE_IP}"
|
||||||
echo "Starting nodes with $bootnodes ..."
|
echo "Starting nodes with $bootnodes ..."
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ do
|
||||||
bootnodes="${bootnodes},$line"
|
bootnodes="${bootnodes},$line"
|
||||||
fi
|
fi
|
||||||
done < "$input"
|
done < "$input"
|
||||||
|
|
||||||
#check last line since it's not included in "read" command https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line
|
#check last line since it's not included in "read" command https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line
|
||||||
if [ -z "${bootnodes}" ]
|
if [ -z "${bootnodes}" ]
|
||||||
then
|
then
|
||||||
|
|
@ -72,23 +73,42 @@ fi
|
||||||
sync_mode=full
|
sync_mode=full
|
||||||
if test -z "$SYNC_MODE"
|
if test -z "$SYNC_MODE"
|
||||||
then
|
then
|
||||||
echo "SYNC_MODE not set, default to full" #full or fast
|
echo "SYNC_MODE not set, default to $sync_mode" #full or fast
|
||||||
else
|
else
|
||||||
echo "SYNC_MODE found, set to $SYNC_MODE"
|
echo "SYNC_MODE found, set to $SYNC_MODE"
|
||||||
sync_mode=$SYNC_MODE
|
sync_mode=$SYNC_MODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gc_mode=archive
|
gc_mode=full
|
||||||
if test -z "$GC_MODE"
|
if test -z "$GC_MODE"
|
||||||
then
|
then
|
||||||
echo "GC_MODE not set, default to archive" #full or archive
|
echo "GC_MODE not set, default to $gc_mode" #full or archive
|
||||||
else
|
else
|
||||||
echo "GC_MODE found, set to $GC_MODE"
|
echo "GC_MODE found, set to $GC_MODE"
|
||||||
gc_mode=$GC_MODE
|
gc_mode=$GC_MODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ethstats_address=stats.apothem.network:2000
|
||||||
|
if test -z "$STATS_ADDRESS"
|
||||||
|
then
|
||||||
|
echo "STATS_ADDRESS not set, default to $ethstats_address"
|
||||||
|
else
|
||||||
|
echo "STATS_ADDRESS found, set to $STATS_ADDRESS"
|
||||||
|
ethstats_address=$STATS_ADDRESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
ethstats_secret=xdc_xinfin_apothem_network_stats
|
||||||
|
if test -z "$STATS_SECRET"
|
||||||
|
then
|
||||||
|
echo "STATS_SECRET not set, default to $ethstats_secret"
|
||||||
|
else
|
||||||
|
echo "STATS_SECRET found, set to $STATS_SECRET"
|
||||||
|
ethstats_secret=$STATS_SECRET
|
||||||
|
fi
|
||||||
|
|
||||||
|
netstats="${NODE_NAME}-${wallet}:$ethstats_secret@$ethstats_address"
|
||||||
|
|
||||||
INSTANCE_IP=$(curl https://checkip.amazonaws.com)
|
INSTANCE_IP=$(curl https://checkip.amazonaws.com)
|
||||||
netstats="${NODE_NAME}-${wallet}-${INSTANCE_IP}:xdc_xinfin_apothem_network_stats@stats.apothem.network:2000"
|
|
||||||
|
|
||||||
|
|
||||||
echo "Running a node with wallet: ${wallet} at IP: ${INSTANCE_IP}"
|
echo "Running a node with wallet: ${wallet} at IP: ${INSTANCE_IP}"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/accounts"
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
"github.com/XinFinOrg/XDPoSChain/common"
|
||||||
"github.com/XinFinOrg/XDPoSChain/common/mclock"
|
"github.com/XinFinOrg/XDPoSChain/common/mclock"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus"
|
"github.com/XinFinOrg/XDPoSChain/consensus"
|
||||||
|
|
@ -78,6 +79,7 @@ type backend interface {
|
||||||
Downloader() *downloader.Downloader
|
Downloader() *downloader.Downloader
|
||||||
Engine() consensus.Engine
|
Engine() consensus.Engine
|
||||||
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
|
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
|
||||||
|
AccountManager() *accounts.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
// fullNodeBackend encompasses the functionality necessary for a full node
|
// fullNodeBackend encompasses the functionality necessary for a full node
|
||||||
|
|
@ -103,9 +105,10 @@ type Service struct {
|
||||||
backend backend
|
backend backend
|
||||||
engine consensus.Engine // Consensus engine to retrieve variadic block fields
|
engine consensus.Engine // Consensus engine to retrieve variadic block fields
|
||||||
|
|
||||||
node string // Name of the node to display on the monitoring page
|
node string // Name of the node to display on the monitoring page
|
||||||
pass string // Password to authorize access to the monitoring page
|
coinbase string // Coinbase address of the node
|
||||||
host string // Remote address of the monitoring service
|
pass string // Password to authorize access to the monitoring page
|
||||||
|
host string // Remote address of the monitoring service
|
||||||
|
|
||||||
pongCh chan struct{} // Pong notifications are fed into this channel
|
pongCh chan struct{} // Pong notifications are fed into this channel
|
||||||
histCh chan []uint64 // History request block numbers are fed into this channel
|
histCh chan []uint64 // History request block numbers are fed into this channel
|
||||||
|
|
@ -195,14 +198,23 @@ func New(node *node.Node, backend backend, engine consensus.Engine, url string)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ethstats := &Service{
|
ethstats := &Service{
|
||||||
backend: backend,
|
backend: backend,
|
||||||
engine: engine,
|
engine: engine,
|
||||||
server: node.Server(),
|
server: node.Server(),
|
||||||
node: parts[0],
|
node: parts[0],
|
||||||
pass: parts[1],
|
coinbase: "", // will be set below
|
||||||
host: parts[2],
|
pass: parts[1],
|
||||||
pongCh: make(chan struct{}),
|
host: parts[2],
|
||||||
histCh: make(chan []uint64, 1),
|
pongCh: make(chan struct{}),
|
||||||
|
histCh: make(chan []uint64, 1),
|
||||||
|
}
|
||||||
|
|
||||||
|
if am := backend.AccountManager(); am != nil {
|
||||||
|
accounts := am.Accounts()
|
||||||
|
if len(accounts) > 0 {
|
||||||
|
coinbase := accounts[0]
|
||||||
|
ethstats.coinbase = coinbase.String0x()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.RegisterLifecycle(ethstats)
|
node.RegisterLifecycle(ethstats)
|
||||||
|
|
@ -480,6 +492,7 @@ func (s *Service) readLoop(conn *connWrapper) {
|
||||||
type nodeInfo struct {
|
type nodeInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Node string `json:"node"`
|
Node string `json:"node"`
|
||||||
|
Coinbase string `json:"coinbase"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Network string `json:"net"`
|
Network string `json:"net"`
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
|
|
@ -512,8 +525,9 @@ func (s *Service) login(conn *connWrapper) error {
|
||||||
auth := &authMsg{
|
auth := &authMsg{
|
||||||
ID: s.node,
|
ID: s.node,
|
||||||
Info: nodeInfo{
|
Info: nodeInfo{
|
||||||
Name: s.node,
|
Name: s.node,
|
||||||
Node: infos.Name,
|
Node: infos.Name,
|
||||||
|
Coinbase: s.coinbase,
|
||||||
Port: infos.Ports.Listener,
|
Port: infos.Ports.Listener,
|
||||||
Network: network,
|
Network: network,
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue