We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45e63a1 commit ff769cdCopy full SHA for ff769cd
rolling-shutter/medley/encodeable/number/block.go
@@ -2,6 +2,7 @@ package number
2
3
import (
4
"bytes"
5
+ "errors"
6
"math/big"
7
)
8
@@ -11,6 +12,8 @@ var (
11
12
LatestStr = []byte("latest")
13
14
15
+var ErrLatestBlockToUint = errors.New("'latest' block can't be converted to uint64")
16
+
17
func BigToBlockNumber(i *big.Int) *BlockNumber {
18
return &BlockNumber{
19
Int: i,
@@ -46,6 +49,14 @@ func (k *BlockNumber) IsLatest() bool {
46
49
return k.Equal(LatestBlock)
47
50
}
48
51
52
+func (k *BlockNumber) ToUInt64() (uint64, error) {
53
+ p := k.ToUInt64Ptr()
54
+ if p == nil {
55
+ return 0, ErrLatestBlockToUint
56
+ }
57
+ return *p, nil
58
+}
59
60
func (k *BlockNumber) ToUInt64Ptr() *uint64 {
61
if k.IsLatest() {
62
return nil
0 commit comments