2021-07-14 15:13:27 +00:00
|
|
|
# Nimbus
|
2024-02-13 09:49:41 +00:00
|
|
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
2021-07-14 15:13:27 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2023-02-14 20:27:17 +00:00
|
|
|
{.push raises: [].}
|
|
|
|
|
2021-07-14 15:13:27 +00:00
|
|
|
import
|
2024-12-13 05:12:57 +00:00
|
|
|
../../common/common
|
2022-12-02 04:35:41 +00:00
|
|
|
|
|
|
|
export
|
|
|
|
common
|
2021-07-14 15:13:27 +00:00
|
|
|
|
|
|
|
type
|
2022-12-02 04:35:41 +00:00
|
|
|
ChainRef* = ref object of RootRef
|
|
|
|
com: CommonRef
|
|
|
|
## common block chain configuration
|
|
|
|
## used throughout entire app
|
2022-05-09 14:04:48 +00:00
|
|
|
|
2021-07-14 15:13:27 +00:00
|
|
|
extraValidation: bool ##\
|
2021-07-30 14:06:51 +00:00
|
|
|
## Trigger extra validation, currently within `persistBlocks()`
|
|
|
|
## function only.
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public constructors
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-06-16 03:22:06 +00:00
|
|
|
func newChain*(com: CommonRef,
|
2024-12-18 04:04:23 +00:00
|
|
|
extraValidation: bool = true): ChainRef =
|
2022-12-05 11:25:44 +00:00
|
|
|
## Constructor for the `Chain` descriptor object.
|
|
|
|
## The argument `extraValidation` enables extra block
|
2021-07-30 14:06:51 +00:00
|
|
|
## chain validation if set `true`.
|
2023-10-05 03:04:12 +00:00
|
|
|
ChainRef(
|
|
|
|
com: com,
|
2024-12-13 05:12:57 +00:00
|
|
|
extraValidation: extraValidation
|
2023-10-05 03:04:12 +00:00
|
|
|
)
|
2021-07-30 14:06:51 +00:00
|
|
|
|
2021-07-14 15:13:27 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public `Chain` getters
|
|
|
|
# ------------------------------------------------------------------------------
|
2023-10-05 03:04:12 +00:00
|
|
|
|
2024-06-16 03:22:06 +00:00
|
|
|
func db*(c: ChainRef): CoreDbRef =
|
2021-07-14 15:13:27 +00:00
|
|
|
## Getter
|
2022-12-02 04:35:41 +00:00
|
|
|
c.com.db
|
2021-07-14 15:13:27 +00:00
|
|
|
|
2024-06-16 03:22:06 +00:00
|
|
|
func com*(c: ChainRef): CommonRef =
|
2022-09-16 04:23:25 +00:00
|
|
|
## Getter
|
2022-12-02 04:35:41 +00:00
|
|
|
c.com
|
2022-09-16 04:23:25 +00:00
|
|
|
|
2024-06-16 03:22:06 +00:00
|
|
|
func extraValidation*(c: ChainRef): bool =
|
2021-07-14 15:13:27 +00:00
|
|
|
## Getter
|
2022-12-02 04:35:41 +00:00
|
|
|
c.extraValidation
|
2021-07-14 15:13:27 +00:00
|
|
|
|
2021-07-30 14:06:51 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public `Chain` setters
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-06-16 03:22:06 +00:00
|
|
|
func `extraValidation=`*(c: ChainRef; extraValidation: bool) =
|
2021-07-30 14:06:51 +00:00
|
|
|
## Setter. If set `true`, the assignment value `extraValidation` enables
|
|
|
|
## extra block chain validation.
|
|
|
|
c.extraValidation = extraValidation
|
|
|
|
|
2021-07-14 15:13:27 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|