ipld-eth-server/pkg/observers/blockchain_logging_observer.go
Matt K 266c9587c8 Canonical blocks (#108)
* Update Block w/ newest Block

* Add cascading delete to blocks and transactions tables

* Add handling for new conflicting blocks

* Command line version of sliding window n behind HEAD
2017-12-19 14:14:41 -06:00

33 lines
673 B
Go

package observers
import (
"os"
"text/template"
"time"
"github.com/8thlight/vulcanizedb/pkg/core"
)
const blockAddedTemplate = `
New block was added: {{.Number}}
Time: {{.Time | unix_time}}
Gas Limit: {{.GasLimit}}
Gas Used: {{.GasUsed}}
Number of Transactions {{.Transactions | len}}
`
var funcMap = template.FuncMap{
"unix_time": func(n int64) time.Time {
return time.Unix(n, 0)
},
}
var tmp = template.Must(template.New("window").Funcs(funcMap).Parse(blockAddedTemplate))
type BlockchainLoggingObserver struct{}
func (blockchainObserver BlockchainLoggingObserver) NotifyBlockAdded(block core.Block) {
tmp.Execute(os.Stdout, block)
}