mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 19:00:46 +00:00
parent
ad45cb55fe
commit
cf714776ba
2 changed files with 31 additions and 19 deletions
|
|
@ -310,14 +310,6 @@ func (ec *Client) GetTransactionReceiptResult(ctx context.Context, txHash common
|
||||||
return r, result, err
|
return r, result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type rpcProgress struct {
|
|
||||||
StartingBlock hexutil.Uint64
|
|
||||||
CurrentBlock hexutil.Uint64
|
|
||||||
HighestBlock hexutil.Uint64
|
|
||||||
PulledStates hexutil.Uint64
|
|
||||||
KnownStates hexutil.Uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// SyncProgress retrieves the current progress of the sync algorithm. If there's
|
// SyncProgress retrieves the current progress of the sync algorithm. If there's
|
||||||
// no sync currently running, it returns nil.
|
// no sync currently running, it returns nil.
|
||||||
func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) {
|
func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) {
|
||||||
|
|
@ -330,17 +322,11 @@ func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, err
|
||||||
if err := json.Unmarshal(raw, &syncing); err == nil {
|
if err := json.Unmarshal(raw, &syncing); err == nil {
|
||||||
return nil, nil // Not syncing (always false)
|
return nil, nil // Not syncing (always false)
|
||||||
}
|
}
|
||||||
var progress *rpcProgress
|
var p *rpcProgress
|
||||||
if err := json.Unmarshal(raw, &progress); err != nil {
|
if err := json.Unmarshal(raw, &p); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return ðereum.SyncProgress{
|
return p.toSyncProgress(), nil
|
||||||
StartingBlock: uint64(progress.StartingBlock),
|
|
||||||
CurrentBlock: uint64(progress.CurrentBlock),
|
|
||||||
HighestBlock: uint64(progress.HighestBlock),
|
|
||||||
PulledStates: uint64(progress.PulledStates),
|
|
||||||
KnownStates: uint64(progress.KnownStates),
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeNewHead subscribes to notifications about the current blockchain head
|
// SubscribeNewHead subscribes to notifications about the current blockchain head
|
||||||
|
|
@ -656,3 +642,26 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
||||||
}
|
}
|
||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rpcProgress is a copy of SyncProgress with hex-encoded fields.
|
||||||
|
type rpcProgress struct {
|
||||||
|
StartingBlock hexutil.Uint64
|
||||||
|
CurrentBlock hexutil.Uint64
|
||||||
|
HighestBlock hexutil.Uint64
|
||||||
|
|
||||||
|
PulledStates hexutil.Uint64
|
||||||
|
KnownStates hexutil.Uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *rpcProgress) toSyncProgress() *ethereum.SyncProgress {
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ðereum.SyncProgress{
|
||||||
|
StartingBlock: uint64(p.StartingBlock),
|
||||||
|
CurrentBlock: uint64(p.CurrentBlock),
|
||||||
|
HighestBlock: uint64(p.HighestBlock),
|
||||||
|
PulledStates: uint64(p.PulledStates),
|
||||||
|
KnownStates: uint64(p.KnownStates),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,9 @@ type SyncProgress struct {
|
||||||
StartingBlock uint64 // Block number where sync began
|
StartingBlock uint64 // Block number where sync began
|
||||||
CurrentBlock uint64 // Current block number where sync is at
|
CurrentBlock uint64 // Current block number where sync is at
|
||||||
HighestBlock uint64 // Highest alleged block number in the chain
|
HighestBlock uint64 // Highest alleged block number in the chain
|
||||||
|
|
||||||
|
// "fast sync" fields. These used to be sent by geth, but are no longer used
|
||||||
|
// since version v1.10.
|
||||||
PulledStates uint64 // Number of state trie entries already downloaded
|
PulledStates uint64 // Number of state trie entries already downloaded
|
||||||
KnownStates uint64 // Total number of state trie entries known about
|
KnownStates uint64 // Total number of state trie entries known about
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue