Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geth v1.9.11 #17

Closed
wants to merge 165 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
00e0056
Write state diff to CSV (#2)
elizabethengelman Jan 28, 2019
837a66a
Apply go fmt changes to statediff
elizabethengelman Jan 30, 2019
ddb53ad
Apply goimports to statediff
elizabethengelman Jan 31, 2019
db01237
Apply gosimple changes to statediff
elizabethengelman Jan 31, 2019
2f34966
Gracefully exit geth command(#4)
elizabethengelman Feb 11, 2019
2b68430
Statediff for full node (#6)
elizabethengelman Feb 21, 2019
e18f462
refactoring/reorganizing packages
i-norden Apr 26, 2019
df1bfba
refactoring statediff builder and types and adjusted to relay proofs …
i-norden Apr 26, 2019
e69ab97
refactoring state diff service and adding api which allows for stream…
i-norden Apr 26, 2019
4e8d812
make proofs and paths optional + compress service loop into single fo…
i-norden May 13, 2019
adf43ec
option to process intermediate nodes
i-norden May 15, 2019
2cf3403
make state diff rlp serializable
i-norden May 16, 2019
ea34704
cli parameter to limit statediffing to select account addresses + test
i-norden May 17, 2019
bed68d4
review fixes and fixes for issues ran into in integration
i-norden May 17, 2019
f682030
review fixes; proper method signature for api; adjust service so that…
i-norden Jun 5, 2019
7096c9c
adjust buffering to improve stability; doc.go; fix notifier
i-norden Jun 7, 2019
a87a06f
relay receipts with the rest of the data + review fixes/changes
i-norden Jul 18, 2019
8c2f200
core: add blockchain test too for revert cornercase
holiman Sep 16, 2019
e00e187
params: release Geth v1.9.7
karalabe Nov 7, 2019
92e94dc
params: begin v1.9.8 release cycle
karalabe Nov 7, 2019
03a3783
p2p/enode: mock DNS resolver in URL parsing test (#20252)
fjl Nov 7, 2019
8a6bd87
travis: enable test suite on ARM64 (#20219)
gballet Nov 8, 2019
8489a29
p2p: fix bug in TestPeerDisconnect (#20277)
Nov 13, 2019
539ca8c
dashboard: send current block to the dashboard client (#19762)
kurkomisi Nov 13, 2019
ff0b463
miner: increase worker test timeout (#20268)
gballet Nov 13, 2019
c255367
les: implement server priority API (#20070)
zsfelfoldi Nov 13, 2019
e2482ae
accounts/abi/bind, cmd/abigen: implement alias for abigen (#20244)
rjl493456442 Nov 14, 2019
a672c10
rpc: fix typo example code (#20284)
Jorropo Nov 14, 2019
e2198a1
cmd/faucet: use github.com/gorilla/websocket (#20283)
fjl Nov 14, 2019
6329ba8
dashboard: remove the dashboard (#20279)
fjl Nov 14, 2019
a747953
whisper/whisperv6: fix staticcheck issues (#20288)
gballet Nov 14, 2019
0e3e967
build: gather info to investigate why builds fail on ARM (#20281)
gballet Nov 14, 2019
3c889e7
params: finish sentence in comment (#20291)
meowsbits Nov 14, 2019
d946ff0
core/vm: fix tracer interface parameter name (#20294)
nebojsa94 Nov 15, 2019
cc86617
internal/ethapi: don't query wallets at every execution of gas estima…
holiman Nov 11, 2019
3c1fbf9
cmd/evm: Allow loading input from file (#20273)
michaelforney Nov 17, 2019
f3fa942
rpc, p2p/simulations: use github.com/gorilla/websocket (#20289)
fjl Nov 18, 2019
cb1ba11
build: use golangci-lint (#20295)
fjl Nov 18, 2019
ef27606
travis: remove traces and use travis_wait in ARM build (#20296)
gballet Nov 18, 2019
3e06a55
core: s/isEIP155/isHomestead/g (fix IntrinsicGas signature var name) …
meowsbits Nov 18, 2019
4f9d21d
les: rename UpdateBalance to AddBalance and simplify return format (#…
zsfelfoldi Nov 18, 2019
0f3164d
travis: use travis_wait for both install and build (#20309)
gballet Nov 18, 2019
efc8f80
build: add test cmd flag -v for verbose logs (#20298)
meowsbits Nov 18, 2019
38888ac
cmd/clef: fix staticcheck warnings (#20314)
fjl Nov 18, 2019
40a8484
consensus/clique: add clique_status API method (#20103)
holiman Nov 18, 2019
5fd9461
consensus/clique: fix struct tags for status API (#20316)
fjl Nov 18, 2019
db93da5
cmd/ethkey: fix file permissions in changepassword command (#20313)
fjl Nov 19, 2019
756ed51
p2p/netutil: fix staticcheck warning (#20315)
fjl Nov 19, 2019
a2ea532
core/rawdb: check hash before return data from ancient db (#20195)
rjl493456442 Nov 19, 2019
c0428c4
travis: deactivate arm build during push (#20321)
gballet Nov 19, 2019
7364229
ethclient: remove use of common.ToHex (#20326)
fjl Nov 19, 2019
b1e2868
cmd/wnode: remove uses of common.ToHex (#20327)
fjl Nov 19, 2019
88e5154
event: remove unused field 'closed' (#20324)
fjl Nov 19, 2019
2153dbe
.github: remove 'nonsense' from CODEOWNERS (#20329)
gballet Nov 19, 2019
b01dccb
whisper/whisperv6: fix staticcheck warnings (#20328)
fjl Nov 19, 2019
2b8f3c4
p2p: remove unused code (#20325)
fjl Nov 19, 2019
67e9f39
p2p/simulations: fix staticcheck warnings (#20322)
fjl Nov 19, 2019
81d1bfd
internal/web3ext, les: update clique JS and make it work with the lig…
fjl Nov 19, 2019
06df38e
rpc: remove 'exported or builtin' restriction for parameters (#20332)
fjl Nov 20, 2019
0cc6974
core: fix staticcheck warnings (#20323)
fjl Nov 20, 2019
af3806f
miner: fix data race in tests (#20310)
rjl493456442 Nov 20, 2019
01a6254
cmd/puppeth: update chain spec of parity (#20241)
rjl493456442 Nov 20, 2019
46496e8
go.mod, vendor: switch to Go modules
karalabe Nov 18, 2019
93bb6c3
travis: explicitly enable go modules in Go 1.11 and 1.12
karalabe Nov 18, 2019
0e8c205
accounts/abi/bind: switch binding test to go modules
karalabe Nov 18, 2019
f19cbb0
travis, build: aggregate and upload go mod dependencies for PPA
karalabe Nov 18, 2019
f024339
go.mod: tidy up the modules to avoid xgo writes to go.sum
karalabe Nov 18, 2019
d83c9fa
build, internal/build: drop own file/folder copier
karalabe Nov 18, 2019
6f31c1f
travis: fake build ppa only for go module dependencies
karalabe Nov 18, 2019
fbc3611
mobile: fix CopyFile switch to package cp
karalabe Nov 18, 2019
c1dabf8
tests: refactor TestState to dedupe walk callback
meowsbits Nov 20, 2019
1887cd7
build, travis: use ephemeral debsrc GOPATH to get mod deps
karalabe Nov 20, 2019
3383739
tests: enable TransactionTests Istanbul case (#20337)
meowsbits Nov 20, 2019
13b28f7
cmd/puppeth: x-spec nonce data type, use types.BlockNonce
meowsbits Nov 20, 2019
419268f
cmd/puppeth: make ssh prompt more user-friendly
holiman Nov 21, 2019
62d423f
common/hexutil: improve GraphQL error messages (#20353)
fjl Nov 21, 2019
3d46043
build: pull in ci.go dependencies for the PPA builder
karalabe Nov 21, 2019
6ccf0a7
common: improve GraphQL error messages (#20354)
fjl Nov 21, 2019
d58ad8d
core/types: remove BlockBy sorting code (#20355)
fjl Nov 21, 2019
7be6449
build: skip go clean on PPA, messes with the module trick
karalabe Nov 21, 2019
76efa96
accounts/abi/bind/backends: remove unused assignment (#20359)
fjl Nov 21, 2019
9fa5359
accounts/abi: fix staticcheck warnings (#20358)
fjl Nov 21, 2019
4c2ce94
core/state: fix staticcheck warnings (#20357)
fjl Nov 22, 2019
747e449
metrics: fix issues reported by staticcheck (#20365)
gballet Nov 22, 2019
30af43f
trie: remove unused code (#20366)
fjl Nov 22, 2019
31cec2a
p2p/discv5: add deprecation warning and remove unused code (#20367)
fjl Nov 22, 2019
eaf136e
tests, signer: remove staticcheck warnings (#20364)
gballet Nov 23, 2019
fca48e2
core/asm: allow numbers in labels (#20362)
michaelforney Nov 23, 2019
d6a0772
miner: fix staticcheck warnings (#20375)
gballet Nov 24, 2019
e3f2545
eth/tracers: fix staticcheck warnings (#20379)
gballet Nov 24, 2019
ab5e0e3
trie: replace bigcache with fastcache (#19971)
rjl493456442 Nov 25, 2019
8e35276
cmd/geth: remove network id from version cmd
meowsbits Nov 25, 2019
397c3e2
rlp: fix staticcheck warnings (#20368)
fjl Nov 25, 2019
0d3bcbb
accounts/abi/bind: avoid reclaring structs (#20381)
rjl493456442 Nov 25, 2019
809a085
accounts/keystore: fix staticcheck warnings (#20373)
gballet Nov 25, 2019
070afb0
p2p/discover: slow down lookups on empty table (#20389)
fjl Nov 26, 2019
946f889
les: fix clientInfo deadlock (#20395)
zsfelfoldi Nov 26, 2019
572d244
params: release go-ethereum v1.9.8
karalabe Nov 26, 2019
3b549fa
params: begin v1.9.9 release cycle
karalabe Nov 26, 2019
d534abf
cmd: fix command help messages in modules (#20203)
zacscoding Nov 26, 2019
3784499
les: fix staticcheck warnings (#20371)
gballet Nov 27, 2019
0046347
core: fix staticcheck warnings (#20384)
gballet Nov 27, 2019
e7a06d5
core/rawdb: fix reinit regression caused by the hash check PR
karalabe Nov 27, 2019
9c04887
deps: update fastcache to 1.5.3
holiman Nov 27, 2019
b41940f
consensus/ethash: refactor remote sealer (#20335)
fjl Nov 28, 2019
e6f0294
log: fix staticcheck warnings (#20388)
gballet Nov 28, 2019
44e7bec
trie: remove dead code (#20405)
rjl493456442 Nov 28, 2019
376e876
cmd/faucet, cmd/geth: fix staticcheck warnings (#20374)
gballet Nov 29, 2019
84ce2ed
internal: fix staticcheck warnings (#20380)
gballet Nov 29, 2019
98e0b8c
accounts/scwallet: fix staticcheck warnings (#20370)
gballet Nov 29, 2019
05b3c16
internal/web3ext: add debug_accountRange (#20410)
xinluyin Nov 29, 2019
db26dfc
accounts/usbwallet: fix staticcheck warnings (#20372)
gballet Nov 29, 2019
72e8fb3
core, miner: remove PostChainEvents (#19396)
rjl493456442 Nov 29, 2019
091e9db
accounts/abi/bind: fix destructive packing of *big.Int (#20412)
MariusVanDerWijden Dec 2, 2019
4c4e8e8
trie: track dirty cache metrics, track clean writes on commit
karalabe Dec 2, 2019
0c7ae69
params: update CHTs for v1.9.9 release
karalabe Dec 5, 2019
04998d1
p2p/enode: remove data race in sliceIter (#20421)
MariusVanDerWijden Dec 5, 2019
e142beb
consensus/ethash, params: eip-2384: bump difficulty bomb (#20347)
holiman Dec 6, 2019
4a2e08d
params: release Geth v1.9.9
karalabe Dec 6, 2019
844ed25
Update test block hashes
elizabethengelman Dec 20, 2019
ed2bc05
Cleanup after rebasing v1.9.9
elizabethengelman Dec 20, 2019
d66903b
Add warning to statediff docs that empty payloads may be sent to sub
elizabethengelman Jan 27, 2020
95203db
Merge pull request #4 from makerdao/statediffing-service
Jan 28, 2020
6ab17fc
Merge pull request #7 from makerdao/statediff-check
Jan 28, 2020
4cc89a5
internal/build: don't crash in DownloadFile when offline (#20595)
fjl Feb 3, 2020
5a9c964
trie: separate hashes and committer, collapse on commit
holiman Feb 3, 2020
33791db
tracers: avoid panic on invalid arguments (#20612)
tintinweb Feb 4, 2020
058a4ac
core/evm: less iteration in blockhash (#20589)
holiman Feb 4, 2020
711ed74
cmd/geth: add 'dumpgenesis' command (#20191)
meowsbits Feb 4, 2020
a1313b5
trie: make hasher parallel when number of changes are large (#20488)
holiman Feb 4, 2020
976a0f5
cmd/devp2p: fix Route53 TXT record splitting (#20626)
fjl Feb 5, 2020
4a231cd
internal/ethapi: return non-null "number" for pending block (#20616)
holiman Feb 7, 2020
675f4e7
README.md: update evm usage example (#20635)
wolflo Feb 9, 2020
34bb132
graphql: add transaction signature values (#20623)
AmitBRD Feb 9, 2020
172f777
rpc: add error when call result parameter is not addressable (#20638)
adamschmideg Feb 11, 2020
8694d14
signer: add bytes32 as valid primitive (#20609)
chabashilah Feb 11, 2020
dcffb77
cmd/geth retesteth: add eth_getBlockByHash (#20621)
winsvega Feb 11, 2020
049e171
core, eth: implement eth/65 transaction fetcher
rjl493456442 Oct 28, 2019
c22fdec
common/mclock: add NewTimer and Timer.Reset (#20634)
fjl Feb 11, 2020
8045504
les: log disconnect reason when light server is not synced (#20643)
adamschmideg Feb 11, 2020
1821328
event: add missing unlock before panic (#20653)
Feb 12, 2020
46c4b69
accounts/abi/bind/backends: add support for historical state (#20644)
MariusVanDerWijden Feb 12, 2020
a9614c3
event, p2p/simulations/adapters: fix rare goroutine leaks (#20657)
Feb 12, 2020
5f2002b
accounts: add walletsNoLock to avoid double read lock (#20655)
Feb 12, 2020
90caa2c
p2p: new dial scheduler (#20592)
fjl Feb 13, 2020
9938d95
eth: rework tx fetcher to use O(1) ops + manage network requests
karalabe Jan 22, 2020
eddcecc
Merge pull request #20234 from rjl493456442/newtxhashes_2
karalabe Feb 13, 2020
38d1b0c
cmd/geth: enable DNS discovery by default (#20660)
fjl Feb 13, 2020
8556905
core: ensure state exists for prefetcher (#20627)
holiman Feb 14, 2020
37531b1
cmd/faucet: protect f.reqs with Rlock to prevent data race (#20669)
BurtonQin Feb 15, 2020
36a1e0b
eth: don't enforce minimum broadcast, fix broadcast test
karalabe Feb 17, 2020
fef8c98
travis, appveyor, build: bump builder Go to 1.13.8
karalabe Feb 17, 2020
26284ec
Merge pull request #20681 from karalabe/go1.13.8
karalabe Feb 17, 2020
ac72787
p2p: remove MeteredPeerEvent (#20679)
fjl Feb 17, 2020
1c4c486
cmd/ethkey: speed up test by using weaker scrypt parameters (#20680)
fjl Feb 17, 2020
c211798
Merge pull request #20678 from karalabe/broadcast-sqrt-proper
karalabe Feb 17, 2020
57d4898
p2p/dnsdisc: re-check tree root when leaf resolution fails (#20682)
fjl Feb 17, 2020
1b9c5b3
all: fix goroutine leaks in unit tests by adding 1-elem channel buffe…
BurtonQin Feb 17, 2020
91b2289
rpc: remove startup error for invalid modules, log it instead (#20684)
fjl Feb 17, 2020
4f55e24
params: update CHTs for the v1.9.11 release
karalabe Feb 18, 2020
05ccbb5
Merge pull request #20687 from karalabe/cht-1.9.11
karalabe Feb 18, 2020
dae3aee
les: add bootstrap nodes as initial discoveries (#20688)
fjl Feb 18, 2020
6a62fe3
params: release Geth v1.9.11 stable
karalabe Feb 18, 2020
b808126
Merge commit '6a62fe399b68ab9e3625ef5e7900394f389adc3a' into geth-v1.…
yaoandrew Feb 21, 2020
60bb77b
Clean up after merge
yaoandrew Feb 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dashboard: send current block to the dashboard client (ethereum#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.

* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
  • Loading branch information
kurkomisi authored and elizabethengelman committed Dec 30, 2019
commit 539ca8c7914845065ad28275f36ffb33d62d7930
5 changes: 5 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
utils.RegisterEthStatsService(stack, cfg.Ethstats.URL)
}

// Add dashboard daemon if requested. This should be the last registered service
// in order to be able to collect information about the other services.
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
utils.RegisterDashboardService(stack, &cfg.Dashboard, gitCommit)
}
return stack
}

Expand Down
13 changes: 11 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1588,9 +1588,18 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) {

// RegisterDashboardService adds a dashboard to the stack.
func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config, commit string) {
stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return dashboard.New(cfg, commit, ctx.ResolvePath("logs")), nil
err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
var (
ethServ *eth.Ethereum
lesServ *les.LightEthereum
)
_ = ctx.Service(&ethServ)
_ = ctx.Service(&lesServ)
return dashboard.New(cfg, ethServ, lesServ, commit, ctx.ResolvePath("logs")), nil
})
if err != nil {
Fatalf("Failed to register the dashboard service: %v", err)
}
}

// RegisterShhService configures Whisper and adds it to the given node.
Expand Down
27,576 changes: 13,981 additions & 13,595 deletions dashboard/assets.go

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions dashboard/assets/components/Chain.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// @flow

// Copyright 2019 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

import React, {Component} from 'react';
import type {Chain as ChainType} from '../types/content';

export const inserter = () => (update: ChainType, prev: ChainType) => {
if (!update.currentBlock) {
return;
}
if (!prev.currentBlock) {
prev.currentBlock = {};
}
prev.currentBlock.number = update.currentBlock.number;
prev.currentBlock.timestamp = update.currentBlock.timestamp;
return prev;
};

// styles contains the constant styles of the component.
const styles = {};

// themeStyles returns the styles generated from the theme for the component.
const themeStyles = theme => ({});

export type Props = {
content: Content,
};

type State = {};

// Logs renders the log page.
class Chain extends Component<Props, State> {
render() {
return <></>;
}
}

export default Chain;
20 changes: 15 additions & 5 deletions dashboard/assets/components/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Header from 'Header';
import Body from 'Body';
import {inserter as logInserter, SAME} from 'Logs';
import {inserter as peerInserter} from 'Network';
import {inserter as chainInserter} from 'Chain';
import {MENU} from '../common';
import type {Content} from '../types/content';

Expand Down Expand Up @@ -83,17 +84,24 @@ const appender = <T>(limit: number, mapper = replacer) => (update: Array<T>, pre
// the execution of unnecessary operations (e.g. copy of the log array).
const defaultContent: () => Content = () => ({
general: {
version: null,
commit: null,
version: null,
genesis: '',
},
home: {},
chain: {
currentBlock: {
number: 0,
timestamp: 0,
},
},
home: {},
chain: {},
txpool: {},
network: {
peers: {
bundles: {},
},
diff: [],
diff: [],
activePeerCount: 0,
},
system: {
activeMemory: [],
Expand Down Expand Up @@ -121,9 +129,10 @@ const updaters = {
general: {
version: replacer,
commit: replacer,
genesis: replacer,
},
home: null,
chain: null,
chain: chainInserter(),
txpool: null,
network: peerInserter(200),
system: {
Expand Down Expand Up @@ -241,6 +250,7 @@ class Dashboard extends Component<Props, State> {
<div className={this.props.classes.dashboard} style={styles.dashboard}>
<Header
switchSideBar={this.switchSideBar}
content={this.state.content}
/>
<Body
opened={this.state.sideBar}
Expand Down
23 changes: 23 additions & 0 deletions dashboard/assets/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import ChartRow from 'ChartRow';
import CustomTooltip, {bytePlotter, bytePerSecPlotter, percentPlotter, multiplier} from 'CustomTooltip';
import {chartStrokeWidth, styles as commonStyles} from '../common';
import type {General, System} from '../types/content';
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faNetworkWired} from "@fortawesome/free-solid-svg-icons";
import Toolbar from "@material-ui/core/Toolbar";

const FOOTER_SYNC_ID = 'footerSyncId';

Expand Down Expand Up @@ -154,6 +157,23 @@ class Footer extends Component<Props, State> {

render() {
const {general, system} = this.props;
let network = '';
switch (general.genesis) {
case '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3':
network = 'main';
break;
case '0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d':
network = 'ropsten';
break;
case '0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177':
network = 'rinkeby';
break;
case '0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a':
network = 'görli';
break;
default:
network = `unknown (${general.genesis.substring(0, 8)})`;
}

return (
<Grid container className={this.props.classes.footer} direction='row' alignItems='center' style={styles.footer}>
Expand Down Expand Up @@ -202,6 +222,9 @@ class Footer extends Component<Props, State> {
</a>
</Typography>
)}
<Typography style={styles.headerText}>
<span style={commonStyles.light}>Network</span> {network}
</Typography>
</Grid>
</Grid>
);
Expand Down
62 changes: 58 additions & 4 deletions dashboard/assets/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,25 @@ import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faBars} from '@fortawesome/free-solid-svg-icons';
import {faBars, faSortAmountUp, faClock, faUsers, faSync} from '@fortawesome/free-solid-svg-icons';
import Typography from '@material-ui/core/Typography';
import type {Content} from '../types/content';


const magnitude = [31536000, 604800, 86400, 3600, 60, 1];
const label = ['y', 'w', 'd', 'h', 'm', 's'];

// styles contains the constant styles of the component.
const styles = {
header: {
height: '8%',
},
headerText: {
marginRight: 15,
},
toolbar: {
height: '100%',
height: '100%',
minHeight: 'unset',
},
};

Expand All @@ -50,16 +59,52 @@ const themeStyles = (theme: Object) => ({
title: {
paddingLeft: theme.spacing.unit,
fontSize: 3 * theme.spacing.unit,
flex: 1,
},
});

export type Props = {
classes: Object, // injected by withStyles()
classes: Object, // injected by withStyles()
switchSideBar: () => void,
content: Content,
networkID: number,
};

type State = {
since: string,
}
// Header renders the header of the dashboard.
class Header extends Component<Props> {
class Header extends Component<Props, State> {
constructor(props) {
super(props);
this.state = {since: ''};
}

componentDidMount() {
this.interval = setInterval(() => this.setState(() => {
// time (seconds) since last block.
let timeDiff = Math.floor((Date.now() - this.props.content.chain.currentBlock.timestamp * 1000) / 1000);
let since = '';
let i = 0;
for (; i < magnitude.length && timeDiff < magnitude[i]; i++);
for (let j = 2; i < magnitude.length && j > 0; j--, i++) {
const t = Math.floor(timeDiff / magnitude[i]);
if (t > 0) {
since += `${t}${label[i]} `;
timeDiff %= magnitude[i];
}
}
if (since === '') {
since = 'now';
}
this.setState({since: since});
}), 1000);
}

componentWillUnmount() {
clearInterval(this.interval);
}

render() {
const {classes} = this.props;

Expand All @@ -72,6 +117,15 @@ class Header extends Component<Props> {
<Typography type='title' color='inherit' noWrap className={classes.title}>
Go Ethereum Dashboard
</Typography>
<Typography style={styles.headerText}>
<FontAwesomeIcon icon={faSortAmountUp} /> {this.props.content.chain.currentBlock.number}
</Typography>
<Typography style={styles.headerText}>
<FontAwesomeIcon icon={faClock} /> {this.state.since}
</Typography>
<Typography style={styles.headerText}>
<FontAwesomeIcon icon={faUsers} /> {this.props.content.network.activePeerCount}
</Typography>
</Toolbar>
</AppBar>
);
Expand Down
5 changes: 4 additions & 1 deletion dashboard/assets/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React, {Component} from 'react';

import withStyles from '@material-ui/core/styles/withStyles';

import Chain from 'Chain';
import Network from 'Network';
import Logs from 'Logs';
import Footer from 'Footer';
Expand Down Expand Up @@ -95,7 +96,9 @@ class Main extends Component<Props, State> {
children = <div>Work in progress.</div>;
break;
case MENU.get('chain').id:
children = <div>Work in progress.</div>;
children = <Chain
content={this.props.content.chain}
/>;
break;
case MENU.get('txpool').id:
children = <div>Work in progress.</div>;
Expand Down
Loading