• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision3c8eaad5e30892cb46f246cdcf1e43c1b3d26dc3 (tree)
Time2019-07-11 12:19:45
Authoroys <oys@oysd...>
Commiteroys

Log Message

optimise

Change Summary

Incremental Difference

--- a/common/address.go
+++ b/common/address.go
@@ -116,7 +116,7 @@ func DecodeAddress(addr string, param *consensus.Params) (Address, error) {
116116 oneIndex := strings.LastIndexByte(addr, '1')
117117 if oneIndex > 1 {
118118 prefix := addr[:oneIndex+1]
119- if strings.ToLower(prefix) == param.Bech32HRPSegwit+"1" {
119+ if IsBech32SegwitPrefix(prefix, param) {
120120 witnessVer, witnessProg, err := decodeSegWitAddress(addr)
121121 if err != nil {
122122 return nil, err
@@ -144,6 +144,13 @@ func DecodeAddress(addr string, param *consensus.Params) (Address, error) {
144144 return nil, ErrUnknownAddressType
145145 }
146146
147+// IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
148+// addresses on any default or registered network. This is used when decoding
149+// an address string into a specific address type.
150+func IsBech32SegwitPrefix(prefix string, params *consensus.Params) bool {
151+ return strings.ToLower(prefix) == params.Bech32HRPSegwit+"1"
152+}
153+
147154 // decodeSegWitAddress parses a bech32 encoded segwit address string and
148155 // returns the witness version and witness program byte representation.
149156 func decodeSegWitAddress(address string) (byte, []byte, error) {
--- a/consensus/general.go
+++ b/consensus/general.go
@@ -99,21 +99,6 @@ type Params struct {
9999 ProducerSubsidys []ProducerSubsidy
100100 }
101101
102-// VaporBasicConfig return the basic config
103-func VaporBasicConfig() BasicConfig {
104- return BasicConfig{
105- MaxBlockGas: uint64(10000000),
106- MaxGasAmount: int64(200000),
107- DefaultGasCredit: int64(160000),
108- StorageGasRate: int64(1),
109- VMGasRate: int64(200),
110-
111- VotePendingBlockNumber: uint64(10000),
112- CoinbasePendingBlockNumber: uint64(100),
113- CoinbaseArbitrarySizeLimit: 128,
114- }
115-}
116-
117102 // VaporDPOSConfig return the dpos consensus config
118103 func VaporDPOSConfig() DPOSConfig {
119104 dpos := DPOSConfig{
@@ -162,9 +147,18 @@ var TestNetParams = Params{
162147 var VaporNetParams = Params{
163148 Name: "vapor",
164149 Bech32HRPSegwit: "vp",
165- BasicConfig: VaporBasicConfig(),
166- DPOSConfig: VaporDPOSConfig(),
167- Checkpoints: []Checkpoint{},
150+ BasicConfig: BasicConfig{
151+ MaxBlockGas: uint64(10000000),
152+ MaxGasAmount: int64(200000),
153+ DefaultGasCredit: int64(160000),
154+ StorageGasRate: int64(1),
155+ VMGasRate: int64(200),
156+ VotePendingBlockNumber: uint64(10000),
157+ CoinbasePendingBlockNumber: uint64(100),
158+ CoinbaseArbitrarySizeLimit: 128,
159+ },
160+ DPOSConfig: VaporDPOSConfig(),
161+ Checkpoints: []Checkpoint{},
168162 ProducerSubsidys: []ProducerSubsidy{
169163 {BeginBlock: 1, EndBlock: 63072000, Subsidy: 15000000},
170164 },
@@ -174,9 +168,18 @@ var VaporNetParams = Params{
174168 var SoloNetParams = Params{
175169 Name: "solo",
176170 Bech32HRPSegwit: "sm",
177- BasicConfig: VaporBasicConfig(),
178- DPOSConfig: VaporDPOSConfig(),
179- Checkpoints: []Checkpoint{},
171+ BasicConfig: BasicConfig{
172+ MaxBlockGas: uint64(10000000),
173+ MaxGasAmount: int64(200000),
174+ DefaultGasCredit: int64(160000),
175+ StorageGasRate: int64(1),
176+ VMGasRate: int64(200),
177+ VotePendingBlockNumber: uint64(10000),
178+ CoinbasePendingBlockNumber: uint64(100),
179+ CoinbaseArbitrarySizeLimit: 128,
180+ },
181+ DPOSConfig: VaporDPOSConfig(),
182+ Checkpoints: []Checkpoint{},
180183 ProducerSubsidys: []ProducerSubsidy{
181184 {BeginBlock: 0, EndBlock: 0, Subsidy: 24},
182185 {BeginBlock: 1, EndBlock: 840000, Subsidy: 24},
Show on old repository browser