File tree Expand file tree Collapse file tree 4 files changed +49
-6
lines changed
scripts/website-staticgen Expand file tree Collapse file tree 4 files changed +49
-6
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ services:
1818 - ' 11211:11211'
1919
2020 db :
21- image : postgres
21+ image : postgres:18
2222 restart : always
2323 volumes :
24- - ' psql_data:/var/lib/postgresql/data '
24+ - ' psql_data:/var/lib/postgresql'
2525 ports :
2626 - ' 5432:5432'
2727 environment :
Original file line number Diff line number Diff line change 55 "fmt"
66 "io"
77 "os"
8+ "time"
89
910 "github.com/flashbots/mev-boost-relay/services/website"
1011 "github.com/goccy/go-json"
@@ -25,6 +26,14 @@ func main() {
2526 panic (err )
2627 }
2728
29+ // add fake times for some variability in rendered template
30+ diff := time .Second
31+ for i , v := range data .Payloads {
32+ v .InsertedAt = time .Now ().Add (- diff )
33+ data .Payloads [i ] = v
34+ diff = diff * 5 / 3
35+ }
36+
2837 indexTemplate , err := website .ParseIndexTemplate ()
2938 if err != nil {
3039 panic (err )
Original file line number Diff line number Diff line change 44 _ "embed"
55 "math/big"
66 "text/template"
7+ "time"
78
89 "github.com/flashbots/mev-boost-relay/database"
910 "golang.org/x/text/cases"
@@ -67,10 +68,39 @@ func caseIt(s string) string {
6768 return caser .String (s )
6869}
6970
71+ func relativeTime (t time.Time ) string {
72+ diff := time .Since (t )
73+ if diff < 0 {
74+ // should be unreachable, but just in case
75+ return diff .String ()
76+ }
77+
78+ seconds := int (diff .Seconds ())
79+ minutes := int (diff .Minutes ())
80+ hours := int (diff .Hours ())
81+ days := hours / 24
82+
83+ if seconds < 60 {
84+ return printer .Sprintf ("%ds ago" , seconds )
85+ } else if minutes < 60 {
86+ return printer .Sprintf ("%dm ago" , minutes )
87+ } else if hours < 24 {
88+ return printer .Sprintf ("%dh ago" , hours )
89+ } else {
90+ return printer .Sprintf ("%dd ago" , days )
91+ }
92+ }
93+
94+ func formatUTC (t time.Time ) string {
95+ return t .UTC ().Format ("2006-01-02 15:04:05 UTC" )
96+ }
97+
7098var funcMap = template.FuncMap {
71- "weiToEth" : weiToEth ,
72- "prettyInt" : prettyInt ,
73- "caseIt" : caseIt ,
99+ "weiToEth" : weiToEth ,
100+ "prettyInt" : prettyInt ,
101+ "caseIt" : caseIt ,
102+ "relativeTime" : relativeTime ,
103+ "formatUTC" : formatUTC ,
74104}
75105
76106//go:embed website.html
Original file line number Diff line number Diff line change 233233 < table class ="pure-table pure-table-horizontal " style ="width:100%; ">
234234 < thead >
235235 < tr >
236+ < th style ="text-align: right; "> Time</ th >
236237 < th > Epoch</ th >
237238 < th > Slot</ th >
238239 < th > Block number</ th >
257258 {{$linkDataAPI := .LinkDataAPI}}
258259 {{ range .Payloads }}
259260 < tr >
261+ < td style ="text-align: right; ">
262+ < span title ="{{.InsertedAt | formatUTC}} "> {{.InsertedAt | relativeTime}}</ span >
263+ </ td >
260264 < td > {{.Epoch | prettyInt}}</ td >
261265 < td >
262266 < a href ="{{$linkDataAPI}}/relay/v1/data/bidtraces/proposer_payload_delivered?slot={{.Slot}} "> {{.Slot | prettyInt}}</ a >
267271 < td >
268272 < div title ="Blob Gas Used: {{.BlobGasUsed}} "> {{.NumBlobs }}</ div >
269273 </ td >
270- < td > {{.BlockHash}}</ td >
274+ < td style =" font-family: monospace; " > {{.BlockHash}}</ td >
271275 < td >
272276 < div class ="icons-container ">
273277 {{ if ne $linkBeaconchain "" }}
You can’t perform that action at this time.
0 commit comments