forked from cerc-io/plugeth
all: fix docstrings
This commit is contained in:
+1
-1
@@ -382,7 +382,7 @@ func (api *LightAPI) LatestCheckpoint() ([4]string, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// GetLocalCheckpoint returns the specific local checkpoint package.
|
||||
// GetCheckpoint returns the specific local checkpoint package.
|
||||
//
|
||||
// The checkpoint package consists of 3 strings:
|
||||
//
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// This is a temporary package whilst working on the eth/66 blocking refactors.
|
||||
// Package downloader is a temporary package whilst working on the eth/66 blocking refactors.
|
||||
// After that work is done, les needs to be refactored to use the new package,
|
||||
// or alternatively use a stripped down version of it. Either way, we need to
|
||||
// keep the changes scoped so duplicating temporarily seems the sanest.
|
||||
|
||||
@@ -124,7 +124,7 @@ func (r *resultStore) getFetchResult(headerNumber uint64) (item *fetchResult, in
|
||||
return item, index, stale, throttle, nil
|
||||
}
|
||||
|
||||
// hasCompletedItems returns true if there are processable items available
|
||||
// HasCompletedItems returns true if there are processable items available
|
||||
// this method is cheaper than countCompleted
|
||||
func (r *resultStore) HasCompletedItems() bool {
|
||||
r.lock.RLock()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// This is a temporary package whilst working on the eth/66 blocking refactors.
|
||||
// Package fetcher is a temporary package whilst working on the eth/66 blocking refactors.
|
||||
// After that work is done, les needs to be refactored to use the new package,
|
||||
// or alternatively use a stripped down version of it. Either way, we need to
|
||||
// keep the changes scoped so duplicating temporarily seems the sanest.
|
||||
|
||||
@@ -153,7 +153,7 @@ func (cm *ClientManager) SetRechargeCurve(curve PieceWiseLinear) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCapacityRaiseThreshold sets a threshold value used for raising capFactor.
|
||||
// SetCapacityLimits sets a threshold value used for raising capFactor.
|
||||
// Either if the difference between total allowed and connected capacity is less
|
||||
// than this threshold or if their ratio is less than capacityRaiseThresholdRatio
|
||||
// then capFactor is allowed to slowly raise.
|
||||
|
||||
+9
-9
@@ -93,7 +93,7 @@ func (r *BlockRequest) Request(reqID uint64, peer *serverPeer) error {
|
||||
return peer.requestBodies(reqID, []common.Hash{r.Hash})
|
||||
}
|
||||
|
||||
// Valid processes an ODR request reply message from the LES network
|
||||
// Validate processes an ODR request reply message from the LES network
|
||||
// returns true and stores results in memory if the message was a valid reply
|
||||
// to the request (implementation of LesOdrRequest)
|
||||
func (r *BlockRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
@@ -151,7 +151,7 @@ func (r *ReceiptsRequest) Request(reqID uint64, peer *serverPeer) error {
|
||||
return peer.requestReceipts(reqID, []common.Hash{r.Hash})
|
||||
}
|
||||
|
||||
// Valid processes an ODR request reply message from the LES network
|
||||
// Validate processes an ODR request reply message from the LES network
|
||||
// returns true and stores results in memory if the message was a valid reply
|
||||
// to the request (implementation of LesOdrRequest)
|
||||
func (r *ReceiptsRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
@@ -213,7 +213,7 @@ func (r *TrieRequest) Request(reqID uint64, peer *serverPeer) error {
|
||||
return peer.requestProofs(reqID, []ProofReq{req})
|
||||
}
|
||||
|
||||
// Valid processes an ODR request reply message from the LES network
|
||||
// Validate processes an ODR request reply message from the LES network
|
||||
// returns true and stores results in memory if the message was a valid reply
|
||||
// to the request (implementation of LesOdrRequest)
|
||||
func (r *TrieRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
@@ -242,7 +242,7 @@ type CodeReq struct {
|
||||
AccKey []byte
|
||||
}
|
||||
|
||||
// ODR request type for node data (used for retrieving contract code), see LesOdrRequest interface
|
||||
// CodeRequest is the ODR request type for node data (used for retrieving contract code), see LesOdrRequest interface
|
||||
type CodeRequest light.CodeRequest
|
||||
|
||||
// GetCost returns the cost of the given ODR request according to the serving
|
||||
@@ -266,7 +266,7 @@ func (r *CodeRequest) Request(reqID uint64, peer *serverPeer) error {
|
||||
return peer.requestCode(reqID, []CodeReq{req})
|
||||
}
|
||||
|
||||
// Valid processes an ODR request reply message from the LES network
|
||||
// Validate processes an ODR request reply message from the LES network
|
||||
// returns true and stores results in memory if the message was a valid reply
|
||||
// to the request (implementation of LesOdrRequest)
|
||||
func (r *CodeRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
@@ -312,7 +312,7 @@ type HelperTrieResps struct { // describes all responses, not just a single one
|
||||
AuxData [][]byte
|
||||
}
|
||||
|
||||
// ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
|
||||
// ChtRequest is the ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
|
||||
type ChtRequest light.ChtRequest
|
||||
|
||||
// GetCost returns the cost of the given ODR request according to the serving
|
||||
@@ -343,7 +343,7 @@ func (r *ChtRequest) Request(reqID uint64, peer *serverPeer) error {
|
||||
return peer.requestHelperTrieProofs(reqID, []HelperTrieReq{req})
|
||||
}
|
||||
|
||||
// Valid processes an ODR request reply message from the LES network
|
||||
// Validate processes an ODR request reply message from the LES network
|
||||
// returns true and stores results in memory if the message was a valid reply
|
||||
// to the request (implementation of LesOdrRequest)
|
||||
func (r *ChtRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
@@ -400,7 +400,7 @@ type BloomReq struct {
|
||||
BloomTrieNum, BitIdx, SectionIndex, FromLevel uint64
|
||||
}
|
||||
|
||||
// ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
|
||||
// BloomRequest is the ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
|
||||
type BloomRequest light.BloomRequest
|
||||
|
||||
// GetCost returns the cost of the given ODR request according to the serving
|
||||
@@ -439,7 +439,7 @@ func (r *BloomRequest) Request(reqID uint64, peer *serverPeer) error {
|
||||
return peer.requestHelperTrieProofs(reqID, reqs)
|
||||
}
|
||||
|
||||
// Valid processes an ODR request reply message from the LES network
|
||||
// Validate processes an ODR request reply message from the LES network
|
||||
// returns true and stores results in memory if the message was a valid reply
|
||||
// to the request (implementation of LesOdrRequest)
|
||||
func (r *BloomRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ var (
|
||||
AdvertiseProtocolVersions = []uint{lpv2} // clients are searching for the first advertised protocol in the list
|
||||
)
|
||||
|
||||
// Number of implemented message corresponding to different protocol versions.
|
||||
// ProtocolLengths is the number of implemented message corresponding to different protocol versions.
|
||||
var ProtocolLengths = map[uint]uint64{lpv2: 22, lpv3: 24, lpv4: 24}
|
||||
|
||||
const (
|
||||
|
||||
+10
-10
@@ -67,13 +67,13 @@ func (e ExpirationFactor) Value(base float64, exp uint64) float64 {
|
||||
return base / e.Factor * math.Pow(2, float64(int64(exp-e.Exp)))
|
||||
}
|
||||
|
||||
// value calculates the value at the given moment.
|
||||
// Value calculates the value at the given moment.
|
||||
func (e ExpiredValue) Value(logOffset Fixed64) uint64 {
|
||||
offset := Uint64ToFixed64(e.Exp) - logOffset
|
||||
return uint64(float64(e.Base) * offset.Pow2())
|
||||
}
|
||||
|
||||
// add adds a signed value at the given moment
|
||||
// Add adds a signed value at the given moment
|
||||
func (e *ExpiredValue) Add(amount int64, logOffset Fixed64) int64 {
|
||||
integer, frac := logOffset.ToUint64(), logOffset.Fraction()
|
||||
factor := frac.Pow2()
|
||||
@@ -102,7 +102,7 @@ func (e *ExpiredValue) Add(amount int64, logOffset Fixed64) int64 {
|
||||
return net
|
||||
}
|
||||
|
||||
// addExp adds another ExpiredValue
|
||||
// AddExp adds another ExpiredValue
|
||||
func (e *ExpiredValue) AddExp(a ExpiredValue) {
|
||||
if e.Exp > a.Exp {
|
||||
a.Base >>= (e.Exp - a.Exp)
|
||||
@@ -114,7 +114,7 @@ func (e *ExpiredValue) AddExp(a ExpiredValue) {
|
||||
e.Base += a.Base
|
||||
}
|
||||
|
||||
// subExp subtracts another ExpiredValue
|
||||
// SubExp subtracts another ExpiredValue
|
||||
func (e *ExpiredValue) SubExp(a ExpiredValue) {
|
||||
if e.Exp > a.Exp {
|
||||
a.Base >>= (e.Exp - a.Exp)
|
||||
@@ -143,7 +143,7 @@ type LinearExpiredValue struct {
|
||||
Rate mclock.AbsTime `rlp:"-"` // Expiration rate(by nanosecond), will ignored by RLP
|
||||
}
|
||||
|
||||
// value calculates the value at the given moment. This function always has the
|
||||
// Value calculates the value at the given moment. This function always has the
|
||||
// assumption that the given timestamp shouldn't less than the recorded one.
|
||||
func (e LinearExpiredValue) Value(now mclock.AbsTime) uint64 {
|
||||
offset := uint64(now / e.Rate)
|
||||
@@ -158,7 +158,7 @@ func (e LinearExpiredValue) Value(now mclock.AbsTime) uint64 {
|
||||
return e.Val
|
||||
}
|
||||
|
||||
// add adds a signed value at the given moment. This function always has the
|
||||
// Add adds a signed value at the given moment. This function always has the
|
||||
// assumption that the given timestamp shouldn't less than the recorded one.
|
||||
func (e *LinearExpiredValue) Add(amount int64, now mclock.AbsTime) uint64 {
|
||||
offset := uint64(now / e.Rate)
|
||||
@@ -244,17 +244,17 @@ func Uint64ToFixed64(f uint64) Fixed64 {
|
||||
return Fixed64(f * fixedFactor)
|
||||
}
|
||||
|
||||
// float64ToFixed64 converts float64 to Fixed64 format.
|
||||
// Float64ToFixed64 converts float64 to Fixed64 format.
|
||||
func Float64ToFixed64(f float64) Fixed64 {
|
||||
return Fixed64(f * fixedFactor)
|
||||
}
|
||||
|
||||
// toUint64 converts Fixed64 format to uint64.
|
||||
// ToUint64 converts Fixed64 format to uint64.
|
||||
func (f64 Fixed64) ToUint64() uint64 {
|
||||
return uint64(f64) / fixedFactor
|
||||
}
|
||||
|
||||
// fraction returns the fractional part of a Fixed64 value.
|
||||
// Fraction returns the fractional part of a Fixed64 value.
|
||||
func (f64 Fixed64) Fraction() Fixed64 {
|
||||
return f64 % fixedFactor
|
||||
}
|
||||
@@ -264,7 +264,7 @@ var (
|
||||
fixedToLogFactor = math.Log(2) / float64(fixedFactor)
|
||||
)
|
||||
|
||||
// pow2Fixed returns the base 2 power of the fixed point value.
|
||||
// Pow2 returns the base 2 power of the fixed point value.
|
||||
func (f64 Fixed64) Pow2() float64 {
|
||||
return math.Exp(float64(f64) * fixedToLogFactor)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ type nodeHistoryEnc struct {
|
||||
RedialWaitStart, RedialWaitEnd uint64
|
||||
}
|
||||
|
||||
// queryFunc sends a pre-negotiation query and blocks until a response arrives or timeout occurs.
|
||||
// QueryFunc sends a pre-negotiation query and blocks until a response arrives or timeout occurs.
|
||||
// It returns 1 if the remote node has confirmed that connection is possible, 0 if not
|
||||
// possible and -1 if no response arrived (timeout).
|
||||
type QueryFunc func(*enode.Node) int
|
||||
@@ -302,7 +302,7 @@ func (s *ServerPool) addPreNegFilter(input enode.Iterator, query QueryFunc) enod
|
||||
})
|
||||
}
|
||||
|
||||
// start starts the server pool. Note that NodeStateMachine should be started first.
|
||||
// Start starts the server pool. Note that NodeStateMachine should be started first.
|
||||
func (s *ServerPool) Start() {
|
||||
s.ns.Start()
|
||||
for _, iter := range s.mixSources {
|
||||
@@ -336,7 +336,7 @@ func (s *ServerPool) Start() {
|
||||
atomic.StoreUint32(&s.started, 1)
|
||||
}
|
||||
|
||||
// stop stops the server pool
|
||||
// Stop stops the server pool
|
||||
func (s *ServerPool) Stop() {
|
||||
if s.fillSet != nil {
|
||||
s.fillSet.Close()
|
||||
|
||||
@@ -233,7 +233,7 @@ func (vt *ValueTracker) StatsExpirer() *utils.Expirer {
|
||||
return &vt.statsExpirer
|
||||
}
|
||||
|
||||
// StatsExpirer returns the current expiration factor so that other values can be expired
|
||||
// StatsExpFactor returns the current expiration factor so that other values can be expired
|
||||
// with the same rate as the service value statistics.
|
||||
func (vt *ValueTracker) StatsExpFactor() utils.ExpirationFactor {
|
||||
vt.statsExpLock.RLock()
|
||||
|
||||
@@ -50,7 +50,7 @@ type (
|
||||
Bias uint64 // seconds
|
||||
AddTokens []IntOrInf
|
||||
}
|
||||
// CapacityQueryReq is the encoding format of the response to the capacity query
|
||||
// CapacityQueryReply is the encoding format of the response to the capacity query
|
||||
CapacityQueryReply []uint64
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user