MCPcopy Create free account
hub / github.com/CPChain/chain / GetBlockNumber

Method GetBlockNumber

api/cpclient/cpclient.go:151–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149}
150
151func (c *Client) GetBlockNumber() *big.Int {
152 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
153 defer cancel()
154
155 var lastBlock BlockNumber
156 err := c.c.CallContext(ctx, &lastBlock, "eth_getBlockByNumber", "latest", true)
157 if err != nil {
158 log.Error("can't get latest block:", "err", err)
159 return big.NewInt(0)
160 }
161 number, err := strconv.ParseInt(lastBlock.Number, 0, 64)
162 return big.NewInt(number)
163}
164
165func (c *Client) ChainConfig() (*configs.ChainConfig, error) {
166 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)

Callers

nothing calls this directly

Calls 2

CallContextMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected