Skip to content

Commit de8b272

Browse files
committed
rpc & config & monitor
1 parent 48a2021 commit de8b272

3 files changed

Lines changed: 46 additions & 26 deletions

File tree

config.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2023 The CortexTheseus Authors
2+
// This file is part of the CortexTheseus library.
3+
//
4+
// The CortexTheseus library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The CortexTheseus library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package robot
18+
19+
import (
20+
"time"
21+
)
22+
23+
const (
24+
batch = 4096 * 2 //params.SyncBatch
25+
delay = 12 //params.Delay
26+
timeout = 30 * time.Second
27+
)

monitor.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"errors"
2222
"github.com/CortexFoundation/CortexTheseus/common"
23-
"github.com/CortexFoundation/CortexTheseus/common/hexutil"
2423
"github.com/CortexFoundation/CortexTheseus/common/mclock"
2524
"github.com/CortexFoundation/CortexTheseus/log"
2625
"github.com/CortexFoundation/CortexTheseus/metrics"
@@ -39,12 +38,6 @@ import (
3938
"time"
4039
)
4140

42-
const (
43-
batch = 4096 * 2 //params.SyncBatch
44-
delay = 12 //params.Delay
45-
timeout = 30 * time.Second
46-
)
47-
4841
var (
4942
rpcBlockMeter = metrics.NewRegisteredMeter("torrent/block/call", nil)
5043
rpcCurrentMeter = metrics.NewRegisteredMeter("torrent/current/call", nil)
@@ -508,25 +501,6 @@ func (m *Monitor) syncLatestBlock() {
508501
}
509502
}
510503

511-
func (m *Monitor) currentBlock() (uint64, bool, error) {
512-
var (
513-
currentNumber hexutil.Uint64
514-
update bool
515-
)
516-
517-
rpcCurrentMeter.Mark(1)
518-
if err := m.cl.Call(&currentNumber, "ctxc_blockNumber"); err != nil {
519-
log.Error("Call ipc method ctxc_blockNumber failed", "error", err)
520-
return m.currentNumber.Load(), false, err
521-
}
522-
if m.currentNumber.Load() != uint64(currentNumber) {
523-
m.currentNumber.Store(uint64(currentNumber))
524-
update = true
525-
}
526-
527-
return uint64(currentNumber), update, nil
528-
}
529-
530504
func (m *Monitor) skip(i uint64) bool {
531505
if m.srv.Load() != SRV_MODEL {
532506
return false

rpc.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,22 @@ func (m *Monitor) getReceipt(tx string) (receipt types.Receipt, err error) {
119119

120120
return
121121
}
122+
123+
func (m *Monitor) currentBlock() (uint64, bool, error) {
124+
var (
125+
currentNumber hexutil.Uint64
126+
update bool
127+
)
128+
129+
rpcCurrentMeter.Mark(1)
130+
if err := m.cl.Call(&currentNumber, "ctxc_blockNumber"); err != nil {
131+
log.Error("Call ipc method ctxc_blockNumber failed", "error", err)
132+
return m.currentNumber.Load(), false, err
133+
}
134+
if m.currentNumber.Load() != uint64(currentNumber) {
135+
m.currentNumber.Store(uint64(currentNumber))
136+
update = true
137+
}
138+
139+
return uint64(currentNumber), update, nil
140+
}

0 commit comments

Comments
 (0)