forked from aergoio/aergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.go
50 lines (42 loc) · 1.15 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @file
* @copyright defined in aergo/LICENSE.txt
*/
package chain
import (
"errors"
"github.com/aergoio/aergo/internal/enc"
"github.com/aergoio/aergo/types"
)
var (
// MaxBlockSize is the maximum size of a block.
MaxBlockSize uint32
CoinbaseAccount []byte
CoinbaseFee uint64
MaxAnchorCount int
UseFastSyncer bool
)
var (
ErrInvalidCoinbaseAccount = errors.New("invalid coinbase account in config")
)
// Init initializes the blockchain-related parameters.
func Init(maxBlockSize uint32, coinbaseAccountStr string, coinbaseFee uint64, isBp bool, maxAnchorCount int, useFastSyncer bool) error {
var err error
MaxBlockSize = maxBlockSize
if isBp {
if len(coinbaseAccountStr) != 0 {
CoinbaseAccount, err = types.DecodeAddress(coinbaseAccountStr)
if err != nil {
return ErrInvalidCoinbaseAccount
}
logger.Info().Str("account", enc.ToString(CoinbaseAccount)).Str("str", coinbaseAccountStr).
Msg("set coinbase account")
} else {
logger.Info().Msg("Coinbase Account is nil, so BP reward will be discarded")
}
}
CoinbaseFee = coinbaseFee
MaxAnchorCount = maxAnchorCount
UseFastSyncer = useFastSyncer
return nil
}