Skip to content

Commit a6c974c

Browse files
otherviewpaologalligitdarrenvechainlibotony
authored
Tweaks to comments (#1444)
* Tweaks to comments * change comment to decreaseStake in staker.sol * Update packer/packer.go * Fixed multiplier * chore: update scheduler comment (#1445) * update comment in engine * decode err --------- Co-authored-by: paologalligit <paolo.galli@vechain.org> Co-authored-by: Darren Kelly <107671032+darrenvechain@users.noreply.github.com> Co-authored-by: tony <liboliqi@gmail.com>
1 parent 55dfff0 commit a6c974c

File tree

8 files changed

+15
-23
lines changed

8 files changed

+15
-23
lines changed

‎bft/engine.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ func (engine *Engine) computeState(header *block.Header) (*bftState, error) {
305305
js = (entry.Value).(*justifier)
306306
end = header.Number()
307307
} else {
308+
// create a new vote set if cache missed or new block is checkpoint
308309
var err error
309310
js, err = engine.newJustifier(header.ParentID())
310311
if err != nil {
@@ -340,7 +341,7 @@ func (engine *Engine) computeState(header *block.Header) (*bftState, error) {
340341
}
341342
weight = validator.Weight
342343
}
343-
// If PoS is not active or error occurred, weight remains nil
344+
// If PoS is not active or error occurred, weight remains 0
344345
js.AddBlock(signer, h.COM(), weight)
345346
} else {
346347
js.AddBlock(signer, h.COM(), 0)

‎bft/justifier.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func (js *justifier) AddBlock(signer thor.Address, isCOM bool, weight uint64) {
124124
}
125125
}
126126

127+
// Summarize summarizes the state of vote set.
127128
func (js *justifier) Summarize() *bftState {
128129
var justified, committed bool
129130

‎builtin/gen/compiled/Staker.bin-runtime‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎builtin/gen/staker.sol‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ contract Staker {
7272
}
7373

7474
/**
75-
* @dev decreaseStake removes VET from the current stake of an active validator
75+
* @dev decreaseStake removes VET from the current stake of an active validator but do not change
76+
the effectiveVET since it will require withdrawStake.
7677
*/
7778
function decreaseStake(
7879
address validator,
@@ -107,7 +108,7 @@ contract Staker {
107108
*/
108109
function addDelegation(
109110
address validator,
110-
uint8 multiplier // (% of msg.value) 100 for x1, 200 for x2, etc. This enforces a maximum of 2.56x multiplier
111+
uint8 multiplier // (% of msg.value) 100 for x1, 200 for x2, etc. This enforces a maximum of 2.55x multiplier
111112
)
112113
external
113114
payable

‎cmd/thor/flags.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ var (
201201
// solo mode only flags
202202
hayabusaFlag = cli.BoolFlag{
203203
Name: "hayabusa",
204-
Usage: "start solo immidetaly as hayabusa",
204+
Usage: "start solo immediately as hayabusa",
205205
}
206206
onDemandFlag = cli.BoolFlag{
207207
Name: "on-demand",

‎comm/sync.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func decodeAndWarmupBatches(ctx context.Context, rawBatches <-chan rawBlockBatch
113113
for batch := range rawBatches {
114114
for i, raw := range batch.rawBlocks {
115115
var blk block.Block
116-
if decodeErr := rlp.DecodeBytes(raw, &blk); err != nil {
117-
err = errors.Wrap(decodeErr, "invalid block")
116+
if err = rlp.DecodeBytes(raw, &blk); err != nil {
117+
err = errors.Wrap(err, "invalid block")
118118
return
119119
}
120120

‎pos/sched.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Scheduler struct {
3737

3838
// NewScheduler create a Scheduler object.
3939
// `addr` is the proposer to be scheduled.
40-
// If `addr` is not listed in `proposers` or not active, an error returned.
40+
// If `addr` is not listed in `proposers`, an error is returned.
4141
func NewScheduler(
4242
addr thor.Address,
4343
proposers []Proposer,

‎thorclient/httpclient/client.go‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"net/http"
1717
"strconv"
1818
"strings"
19-
"sync/atomic"
2019

2120
"github.com/vechain/thor/v2/api"
2221
"github.com/vechain/thor/v2/api/transactions"
@@ -36,9 +35,8 @@ const (
3635
// Client represents the HTTP client for interacting with the VeChainThor blockchain.
3736
// It manages communication via HTTP requests.
3837
type Client struct {
39-
url string
40-
c *http.Client
41-
genesis atomic.Pointer[api.JSONCollapsedBlock]
38+
url string
39+
c *http.Client
4240
}
4341

4442
// New creates a new Client with the provided URL.
@@ -48,9 +46,8 @@ func New(url string) *Client {
4846

4947
func NewWithHTTP(url string, c *http.Client) *Client {
5048
return &Client{
51-
url: url,
52-
c: c,
53-
genesis: atomic.Pointer[api.JSONCollapsedBlock]{},
49+
url: url,
50+
c: c,
5451
}
5552
}
5653

@@ -220,9 +217,6 @@ func (c *Client) SendTransaction(obj *api.RawTx) (*api.SendTxResult, error) {
220217

221218
// GetBlock retrieves a block by its block ID.
222219
func (c *Client) GetBlock(blockID string) (*api.JSONCollapsedBlock, error) {
223-
if blockID == "0" && c.genesis.Load() != nil {
224-
return c.genesis.Load(), nil
225-
}
226220
body, err := c.httpGET(c.url + "/blocks/" + blockID)
227221
if err != nil {
228222
return nil, fmt.Errorf("unable to retrieve block - %w", err)
@@ -237,11 +231,6 @@ func (c *Client) GetBlock(blockID string) (*api.JSONCollapsedBlock, error) {
237231
return nil, fmt.Errorf("unable to unmarshal block - %w", err)
238232
}
239233

240-
if block.Number == 0 {
241-
// Cache the genesis block for future requests
242-
c.genesis.Store(&block)
243-
}
244-
245234
return &block, nil
246235
}
247236

0 commit comments

Comments
 (0)