Merge pull request #283 from aeternity/GH-3002-blockhash_at_current_height

Document Chain.block_hash at current height
This commit is contained in:
Hans Svensson 2020-10-08 10:48:41 +02:00 committed by GitHub
commit 079b3a45c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -678,7 +678,12 @@ The balance of account `a`.
Chain.block_hash(h : int) : option(bytes(32))
```
The hash of the block at height `h`.
The hash of the block at height `h`. `h` has to be within 256 blocks from the
current height of the chain or else the function will return `None`.
NOTE: In AEVM and FATE VM version 1 `Chain.block_height` was not considered an
allowed height. From FATE VM version 2 (IRIS) it will return the block hash of
the current generation.
#### block_height
@ -1218,7 +1223,7 @@ will yield `None`.
#### choose
```
Option.choose(o1 : option('a), o2 : option('a)) : option('a)
Option.choose(o1 : option('a), o2 : option('a)) : option('a)
```
Out of two `option`s choose the one that is `Some`, or `None` if both are `None`s.
@ -1446,7 +1451,7 @@ Func.curry2(f : ('a, 'b) => 'c) : 'a => ('b => 'c)
Func.curry3(f : ('a, 'b, 'c) => 'd) : 'a => ('b => ('c => 'd))
```
Turns a function that takes n arguments into a curried function that takes
Turns a function that takes n arguments into a curried function that takes
one argument and returns a function that waits for the rest in the same
manner. For instance `curry2((a, b) => a + b)(1)(2) == 3`.
@ -1844,7 +1849,7 @@ This namespace provides operations on rational numbers. A rational number is rep
as a fraction of two integers which are stored internally in the `frac` datatype.
The datatype consists of three constructors `Neg/2`, `Zero/0` and `Pos/2` which determine the
sign of the number. Both values stored in `Neg` and `Pos` need to be strictly positive
sign of the number. Both values stored in `Neg` and `Pos` need to be strictly positive
integers. However, when creating a `frac` you should never use the constructors explicitly.
Instead of that, always use provided functions like `make_frac` or `from_int`. This helps
keeping the internal representation well defined.
@ -1869,7 +1874,7 @@ You should use [lt](#lt), [geq](#geq), [eq](#eq) etc instead.
datatype frac = Pos(int, int) | Zero | Neg(int, int)
```
Internal representation of fractional numbers. First integer encodes the numerator and the second the denominator
Internal representation of fractional numbers. First integer encodes the numerator and the second the denominator
both must be always positive, as the sign is being handled by the choice of the constructor.
@ -1993,14 +1998,14 @@ Rounds a fraction to the nearest greater or equal integer.
#### round_to_zero
`Frac.round_to_zero(f : frac) : int`
Rounds a fraction towards zero.
Rounds a fraction towards zero.
Effectively `ceil` if lesser than zero and `floor` if greater.
#### round_from_zero
`Frac.round_from_zero(f : frac) : int`
Rounds a fraction from zero.
Rounds a fraction from zero.
Effectively `ceil` if greater than zero and `floor` if lesser.
@ -2032,7 +2037,7 @@ Subtraction of two fractions.
#### inv
`Frac.inv(a : frac) : frac`
Inverts a fraction. Throws error if `a` is zero.
Inverts a fraction. Throws error if `a` is zero.
#### mul