From ffa13fbfc02e10f4f46407c493b3fc9be53a0c36 Mon Sep 17 00:00:00 2001 From: ucwong Date: Fri, 7 Jul 2023 21:26:17 +0800 Subject: [PATCH 01/17] robot multiple storage engine --- cmd/main.go | 8 +- go.mod | 45 +++++++++ go.sum | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.go | 34 ++++++- 4 files changed, 363 insertions(+), 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 1133bbc..b4bef78 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -33,8 +33,12 @@ func main() { defer m.Stop() go func() { - time.Sleep(5 * time.Second) - m.SwitchService(robot.SRV_MODEL) + for { + m.SwitchService(robot.SRV_PRINT) + time.Sleep(5 * time.Second) + m.SwitchService(robot.SRV_MODEL) + time.Sleep(5 * time.Second) + } }() var c = make(chan os.Signal, 1) diff --git a/go.mod b/go.mod index 505124c..333504c 100644 --- a/go.mod +++ b/go.mod @@ -8,20 +8,65 @@ require ( github.com/CortexFoundation/torrentfs v1.0.51 github.com/google/uuid v1.3.0 github.com/hashicorp/golang-lru v0.5.5-0.20221011183528-d4900dc688bf + github.com/ucwong/golang-kv v1.0.22-0.20230702214711-bd3089dc589a go.etcd.io/bbolt v1.3.7 ) require ( + github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bwmarrin/snowflake v0.3.0 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cockroachdb/errors v1.10.0 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v0.0.0-20230701135918-609ae80aea41 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect github.com/deckarep/golang-set/v2 v2.3.0 // indirect + github.com/dgraph-io/badger/v4 v4.0.2-0.20230612214140-c903578894e4 // indirect + github.com/dgraph-io/ristretto v0.1.1 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/getsentry/sentry-go v0.22.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-stack/stack v1.8.1 // indirect + github.com/gofrs/flock v0.8.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.1.1 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect + github.com/google/flatbuffers v23.5.26+incompatible // indirect github.com/gorilla/websocket v1.5.0 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.4 // indirect github.com/holiman/uint256 v1.2.3-0.20230331162826-e42b95a00943 // indirect + github.com/klauspost/compress v1.16.7 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/nutsdb/nutsdb v0.12.4-0.20230628143711-3843ce89fa65 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/rosedblabs/go-immutable-radix/v2 v2.0.1-0.20230614125820-f2a7bc058c90 // indirect + github.com/rosedblabs/rosedb/v2 v2.2.1 // indirect + github.com/rosedblabs/wal v1.2.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.1 // indirect + github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb // indirect + github.com/xujiajun/mmap-go v1.0.1 // indirect + github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect + golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect + golang.org/x/net v0.11.0 // indirect golang.org/x/sys v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect ) diff --git a/go.sum b/go.sum index 253c301..33456f2 100644 --- a/go.sum +++ b/go.sum @@ -1,48 +1,328 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/CortexFoundation/CortexTheseus v1.10.45 h1:Y8J+R34zCI9Rs+Dtinj2zEOERnd9csVFWakLcJ1d7pw= github.com/CortexFoundation/CortexTheseus v1.10.45/go.mod h1:+Mr47xTwFHzTeFkZB1UN40jVt2XSvRUtwCwgGDEnrVc= github.com/CortexFoundation/merkletree v0.0.0-20230401054716-73abfa6f740b h1:ioI6D7oyKuSjzz54oPCT8ew2BoEz3isiVh5DXRvLEdQ= github.com/CortexFoundation/merkletree v0.0.0-20230401054716-73abfa6f740b/go.mod h1:OwfhC316GcEJ9QVNWPqj6QV7sorcXBnc0P9p8dPfSbM= github.com/CortexFoundation/torrentfs v1.0.51 h1:/dhp12ddBtA22IMbMbYpHAko3pI81FClSAFY/2xiNfA= github.com/CortexFoundation/torrentfs v1.0.51/go.mod h1:T0Z+9qU0yyuk56tJAo950Kum64F7lsdQqGhLK9oCFqo= +github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0 h1:ye3LRgDs6Og7SKC1wBQH8oMaGczhCRpPpnU74l4rma8= +github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= +github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU= +github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230701135918-609ae80aea41 h1:lYBVTS2P5fx79WWjoR/Gf4Fx5sZiIVCFWpuxntyiskY= +github.com/cockroachdb/pebble v0.0.0-20230701135918-609ae80aea41/go.mod h1:FN5O47SBEz5+kO9fG8UTR64g2WS1u5ZFCgTvxGjoSks= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 h1:DJK8W/iB+s/qkTtmXSrHA49lp5O3OsR7E6z4byOLy34= +github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/deckarep/golang-set/v2 v2.3.0 h1:qs18EKUfHm2X9fA50Mr/M5hccg2tNnVqsiBImnyDs0g= github.com/deckarep/golang-set/v2 v2.3.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/dgraph-io/badger/v4 v4.0.2-0.20230612214140-c903578894e4 h1:RayavAsfyodyxbckIyQKfsqXI86te3TRpLBCzk+sjW4= +github.com/dgraph-io/badger/v4 v4.0.2-0.20230612214140-c903578894e4/go.mod h1:hG13KL1kwPRO3+xDiRyIwDmpi5+9U4KPVTr0WRCmf24= +github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= +github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/getsentry/sentry-go v0.22.0 h1:XNX9zKbv7baSEI65l+H1GEJgSeIC1c7EN5kluWaP6dM= +github.com/getsentry/sentry-go v0.22.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw= +github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= +github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/golang-lru v0.5.5-0.20221011183528-d4900dc688bf h1:BQyif+/dqmbIGXyGhe5bDx/3grIchislVu5pK7j/bMQ= github.com/hashicorp/golang-lru v0.5.5-0.20221011183528-d4900dc688bf/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.4 h1:7GHuZcgid37q8o5i3QI9KMT4nCWQQ3Kx3Ov6bb9MfK0= +github.com/hashicorp/golang-lru/v2 v2.0.4/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/holiman/uint256 v1.2.3-0.20230331162826-e42b95a00943 h1:cBubLc/U2uePwv983Br0yfOHdE8/jN1+eQQfhNZonMk= github.com/holiman/uint256 v1.2.3-0.20230331162826-e42b95a00943/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/nutsdb/nutsdb v0.12.4-0.20230628143711-3843ce89fa65 h1:cq0mgmKPtvtA2EmkQ32I+rpk3IIQrGxPW3+OAAIxSZQ= +github.com/nutsdb/nutsdb v0.12.4-0.20230628143711-3843ce89fa65/go.mod h1:FSztXVhUSK5YmedmZQ6m37cU/KpVbGaezUEmUBP8DEo= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= +github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rosedblabs/go-immutable-radix/v2 v2.0.1-0.20230614125820-f2a7bc058c90 h1:AeuxZLgpVnxCjR6mvRJiDQATgOeSme59HX/rWCBjjvw= +github.com/rosedblabs/go-immutable-radix/v2 v2.0.1-0.20230614125820-f2a7bc058c90/go.mod h1:Hk7adp95/ngEfetvapVWdgneuZb15mi9nH/keSH/KqI= +github.com/rosedblabs/rosedb/v2 v2.2.1 h1:gy3W5aerUgmh95gIYcbxBkLFqDFGQuE5cDaWA4OrqfE= +github.com/rosedblabs/rosedb/v2 v2.2.1/go.mod h1:8sgkZQ0Dqz++59nA6JmTHXg1Z9c6hc7DUW78114c7x4= +github.com/rosedblabs/wal v1.2.0 h1:SlF0UUflEbUftW7MnRE0WUdEPCKaAvCxJYzNzdH16bY= +github.com/rosedblabs/wal v1.2.0/go.mod h1:tYh0WapCkDQrID7PNsNHpsZDlkTczJVAFaTySmwaD7U= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb h1:dVZH3AH9f7zB3VBmsjn25B7lfcAyMP4QxdFYTrfj7tg= +github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb/go.mod h1:3yswsBsVuwsOjDvFfC5Na9XSEf4HC7mj3W3g6jvSY/s= +github.com/ucwong/golang-kv v1.0.22-0.20230702214711-bd3089dc589a h1:oXqvqWXZXGA15mx3aO+NmunPKXF71b6EamsQmIuqvzY= +github.com/ucwong/golang-kv v1.0.22-0.20230702214711-bd3089dc589a/go.mod h1:eqqSyzEJQdhdOA+4WCnKBT/zOwjmetsZQDAv6rKtBj8= +github.com/xujiajun/gorouter v1.2.0/go.mod h1:yJrIta+bTNpBM/2UT8hLOaEAFckO+m/qmR3luMIQygM= +github.com/xujiajun/mmap-go v1.0.1 h1:7Se7ss1fLPPRW+ePgqGpCkfGIZzJV6JPq9Wq9iv/WHc= +github.com/xujiajun/mmap-go v1.0.1/go.mod h1:CNN6Sw4SL69Sui00p0zEzcZKbt+5HtEnYUsc6BKKRMg= +github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 h1:w0si+uee0iAaCJO9q86T6yrhdadgcsoNuh47LrUykzg= +github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235/go.mod h1:MR4+0R6A9NS5IABnIM3384FfOq8QFVnm7WDrBOhIaMU= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/monitor.go b/monitor.go index 98711bf..e08975d 100644 --- a/monitor.go +++ b/monitor.go @@ -17,6 +17,7 @@ package robot import ( + "encoding/json" //"context" "errors" "github.com/CortexFoundation/CortexTheseus/common" @@ -30,6 +31,7 @@ import ( "github.com/CortexFoundation/torrentfs/params" "github.com/CortexFoundation/torrentfs/types" lru "github.com/hashicorp/golang-lru" + "github.com/ucwong/golang-kv" "math" "math/big" "runtime" @@ -57,14 +59,15 @@ type Monitor struct { config *params.Config cl *rpc.Client fs *backend.ChainDB + engine kv.Bucket //dl *backend.TorrentManager exitCh chan any terminated atomic.Bool lastNumber atomic.Uint64 startNumber atomic.Uint64 - scope uint64 currentNumber atomic.Uint64 + scope uint64 wg sync.WaitGroup rpcWg sync.WaitGroup @@ -129,6 +132,8 @@ func New(flag *params.Config, cache, compress, listen bool, callback chan any) ( } m.lastNumber.Store(0) m.currentNumber.Store(0) + m.startNumber.Store(0) + m.terminated.Store(false) m.blockCache, _ = lru.New(delay) m.sizeCache, _ = lru.New(batch) @@ -144,6 +149,8 @@ func New(flag *params.Config, cache, compress, listen bool, callback chan any) ( m.srv.Store(SRV_MODEL) + m.engine = kv.Pebble(flag.DataDir) + /*torrents, _ := fs.initTorrents() if m.mode != params.LAZY { for k, v := range torrents { @@ -535,6 +542,11 @@ func (m *Monitor) Stop() { // log.Error("Monitor Fs Manager closed", "error", err) //} + if m.engine != nil { + log.Info("Golang-kv engine close", "engine", m.engine.Name()) + m.engine.Close() + } + if err := m.fs.Close(); err != nil { log.Error("Monitor File Storage closed", "error", err) } @@ -840,7 +852,13 @@ func (m *Monitor) solve(block *types.Block) error { func (m *Monitor) SwitchService(srv int) error { if m.srv.Load() != int32(srv) { m.srv.Store(int32(srv)) - log.Info("Service switch", "srv", m.srv.Load()) + + if m.lastNumber.Load() > 0 { + // TODO record last block according to service category + m.fs.Flush() + m.lastNumber.Store(m.fs.LastListenBlockNumber()) + } + log.Info("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) } return nil } @@ -860,8 +878,20 @@ func (m *Monitor) forPrintService(block *types.Block) error { for _, t := range block.Txs { x := new(big.Float).Quo(new(big.Float).SetInt(t.Amount), new(big.Float).SetInt(big.NewInt(params1.Cortex))) log.Info("Tx print", "hash", t.Hash, "amount", x, "gas", t.GasLimit, "receipt", t.Recipient, "payload", t.Payload) + + if v, err := json.Marshal(t); err != nil { + return err + } else { + m.engine.Set(t.Hash.Bytes(), v) + } } } + + if v, err := json.Marshal(block); err != nil { + return err + } else { + m.engine.Set(block.Hash.Bytes(), v) + } m.fs.Anchor(block.Number) return nil } From c5b4bd5c4732cce9d7cc92920d63c645e828008d Mon Sep 17 00:00:00 2001 From: ucwong Date: Fri, 7 Jul 2023 21:39:47 +0800 Subject: [PATCH 02/17] fix --- monitor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor.go b/monitor.go index e08975d..cfaaf2a 100644 --- a/monitor.go +++ b/monitor.go @@ -851,13 +851,13 @@ func (m *Monitor) solve(block *types.Block) error { func (m *Monitor) SwitchService(srv int) error { if m.srv.Load() != int32(srv) { - m.srv.Store(int32(srv)) - if m.lastNumber.Load() > 0 { - // TODO record last block according to service category + // TODO record last block according to old service category m.fs.Flush() + // TODO load last block according to new service category m.lastNumber.Store(m.fs.LastListenBlockNumber()) } + m.srv.Store(int32(srv)) log.Info("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) } return nil From b35dcd7e0080d27d198d36f97f6ad8f34f3898c4 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 02:21:50 +0800 Subject: [PATCH 03/17] init block and interval fix --- backend/chaindb.go | 4 ++-- cmd/main.go | 6 +++--- monitor.go | 8 ++++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/chaindb.go b/backend/chaindb.go index 80625b1..4cebaea 100644 --- a/backend/chaindb.go +++ b/backend/chaindb.go @@ -136,7 +136,7 @@ func NewChainDB(config *params.Config) (*ChainDB, error) { func (fs *ChainDB) Init() (err error) { fs.initOnce.Do(func() { - if err = fs.initBlockNumber(); err != nil { + if err = fs.InitBlockNumber(); err != nil { log.Error("Init block error", "err", err) //return err } @@ -642,7 +642,7 @@ func (fs *ChainDB) initID() error { }) }*/ -func (fs *ChainDB) initBlockNumber() error { +func (fs *ChainDB) InitBlockNumber() error { return fs.db.Update(func(tx *bolt.Tx) error { buk, err := tx.CreateBucketIfNotExists([]byte(CUR_BLOCK_NUM_ + fs.version)) if err != nil { diff --git a/cmd/main.go b/cmd/main.go index b4bef78..1aaeea1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,7 +4,7 @@ import ( "os" "os/signal" "syscall" - "time" + //"time" "github.com/CortexFoundation/CortexTheseus/log" "github.com/CortexFoundation/robot" @@ -32,14 +32,14 @@ func main() { } defer m.Stop() - go func() { + /*go func() { for { m.SwitchService(robot.SRV_PRINT) time.Sleep(5 * time.Second) m.SwitchService(robot.SRV_MODEL) time.Sleep(5 * time.Second) } - }() + }()*/ var c = make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) diff --git a/monitor.go b/monitor.go index cfaaf2a..2d4d038 100644 --- a/monitor.go +++ b/monitor.go @@ -221,7 +221,6 @@ func (m *Monitor) indexCheck() error { } if checkpoint, ok := params.TrustedCheckpoints[genesis.Hash]; ok { - m.ckp = checkpoint version := m.fs.GetRoot(checkpoint.TfsCheckPoint) @@ -665,7 +664,7 @@ func (m *Monitor) syncLatestBlock() { elapsed := time.Duration(mclock.Now()) - time.Duration(m.start) log.Info("Finish sync, listener will be paused", "current", m.currentNumber.Load(), "elapsed", common.PrettyDuration(elapsed), "progress", progress, "end", end, "last", m.lastNumber.Load()) //return - timer.Reset(time.Millisecond * 1000 * 60) + timer.Reset(time.Millisecond * 1000 * 30) end = false continue } @@ -853,8 +852,11 @@ func (m *Monitor) SwitchService(srv int) error { if m.srv.Load() != int32(srv) { if m.lastNumber.Load() > 0 { // TODO record last block according to old service category + m.fs.Anchor(m.lastNumber.Load()) m.fs.Flush() + // TODO load last block according to new service category + m.fs.InitBlockNumber() m.lastNumber.Store(m.fs.LastListenBlockNumber()) } m.srv.Store(int32(srv)) @@ -905,6 +907,7 @@ func (m *Monitor) forModelService(block *types.Block) error { m.fs.SkipPrint() }() } + if hash, suc := m.blockCache.Get(i); !suc || hash != block.Hash.Hex() { if record, parseErr := m.parseBlockTorrentInfo(block); parseErr != nil { log.Error("Parse new block", "number", block.Number, "block", block, "error", parseErr) @@ -931,5 +934,6 @@ func (m *Monitor) forModelService(block *types.Block) error { } m.blockCache.Add(i, block.Hash.Hex()) } + return nil } From 87fd77ac1581043d3b072001c0683a7c6873bfc7 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 02:36:10 +0800 Subject: [PATCH 04/17] srv storage file path --- monitor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monitor.go b/monitor.go index 2d4d038..4d8e391 100644 --- a/monitor.go +++ b/monitor.go @@ -34,6 +34,7 @@ import ( "github.com/ucwong/golang-kv" "math" "math/big" + "path/filepath" "runtime" "strconv" "sync" @@ -149,7 +150,7 @@ func New(flag *params.Config, cache, compress, listen bool, callback chan any) ( m.srv.Store(SRV_MODEL) - m.engine = kv.Pebble(flag.DataDir) + m.engine = kv.Pebble(filepath.Join(flag.DataDir, ".srv")) /*torrents, _ := fs.initTorrents() if m.mode != params.LAZY { From b80e2fd2f009285d0e37756f5d6024f9bb296157 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 03:01:11 +0800 Subject: [PATCH 05/17] fix --- go.mod | 4 ++-- go.sum | 8 ++++---- monitor.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 333504c..bad242c 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/errors v1.10.0 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20230701135918-609ae80aea41 // indirect + github.com/cockroachdb/pebble v0.0.0-20230707145654-678f7e48216b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect github.com/deckarep/golang-set/v2 v2.3.0 // indirect @@ -64,7 +64,7 @@ require ( go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect - golang.org/x/net v0.11.0 // indirect + golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/go.sum b/go.sum index 33456f2..dc9756f 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+ github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230701135918-609ae80aea41 h1:lYBVTS2P5fx79WWjoR/Gf4Fx5sZiIVCFWpuxntyiskY= -github.com/cockroachdb/pebble v0.0.0-20230701135918-609ae80aea41/go.mod h1:FN5O47SBEz5+kO9fG8UTR64g2WS1u5ZFCgTvxGjoSks= +github.com/cockroachdb/pebble v0.0.0-20230707145654-678f7e48216b h1:hbumHHBHtbYBySgotJ5SPPy/fVsHjub1PyTB8qwvK4k= +github.com/cockroachdb/pebble v0.0.0-20230707145654-678f7e48216b/go.mod h1:FN5O47SBEz5+kO9fG8UTR64g2WS1u5ZFCgTvxGjoSks= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 h1:DJK8W/iB+s/qkTtmXSrHA49lp5O3OsR7E6z4byOLy34= @@ -230,8 +230,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/monitor.go b/monitor.go index 4d8e391..c582173 100644 --- a/monitor.go +++ b/monitor.go @@ -663,9 +663,9 @@ func (m *Monitor) syncLatestBlock() { m.fs.Flush() //go m.exit() elapsed := time.Duration(mclock.Now()) - time.Duration(m.start) - log.Info("Finish sync, listener will be paused", "current", m.currentNumber.Load(), "elapsed", common.PrettyDuration(elapsed), "progress", progress, "end", end, "last", m.lastNumber.Load()) + log.Debug("Finish sync, listener will be paused", "current", m.currentNumber.Load(), "elapsed", common.PrettyDuration(elapsed), "progress", progress, "end", end, "last", m.lastNumber.Load()) //return - timer.Reset(time.Millisecond * 1000 * 30) + timer.Reset(time.Millisecond * 1000 * 15) end = false continue } From 0279b6bf8176607fe822b55b59b1be43d7fb3ba1 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 17:47:00 +0800 Subject: [PATCH 06/17] interval fix --- monitor.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/monitor.go b/monitor.go index c582173..4bd5067 100644 --- a/monitor.go +++ b/monitor.go @@ -646,18 +646,20 @@ func (m *Monitor) syncLatestBlock() { progress = m.syncLastBlock() // Avoid sync in full mode, fresh interval may be less. if progress >= delay { - //timer.Reset(0) end = false - timer.Reset(time.Millisecond * 2000) - } else if progress >= 1 { + timer.Reset(time.Millisecond * 1000) + } else if progress > 1 { end = false - timer.Reset(time.Millisecond * 3000) + timer.Reset(time.Millisecond * 2000) + } else if progress == 1 { + end = true + timer.Reset(time.Millisecond * 13500) } else { if !m.listen { if (m.ckp != nil && m.currentNumber.Load() >= m.ckp.TfsCheckPoint) || (m.ckp == nil && m.currentNumber.Load() > 0) { if !end { end = true - timer.Reset(time.Millisecond * 15000) + timer.Reset(time.Millisecond * 6750) continue } m.fs.Flush() @@ -665,12 +667,12 @@ func (m *Monitor) syncLatestBlock() { elapsed := time.Duration(mclock.Now()) - time.Duration(m.start) log.Debug("Finish sync, listener will be paused", "current", m.currentNumber.Load(), "elapsed", common.PrettyDuration(elapsed), "progress", progress, "end", end, "last", m.lastNumber.Load()) //return - timer.Reset(time.Millisecond * 1000 * 15) + timer.Reset(time.Millisecond * 6750) end = false continue } } - timer.Reset(time.Millisecond * 6000) + timer.Reset(time.Millisecond * 6750) } counter++ if counter%10 == 0 { From d5b2db45a956ecf15029fd68c42844605a0335e9 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 18:41:56 +0800 Subject: [PATCH 07/17] fix --- go.mod | 2 +- go.sum | 4 ++-- monitor.go | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index bad242c..e40922a 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/errors v1.10.0 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20230707145654-678f7e48216b // indirect + github.com/cockroachdb/pebble v0.0.0-20230707214756-fa85ec45a815 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect github.com/deckarep/golang-set/v2 v2.3.0 // indirect diff --git a/go.sum b/go.sum index dc9756f..8d21847 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+ github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230707145654-678f7e48216b h1:hbumHHBHtbYBySgotJ5SPPy/fVsHjub1PyTB8qwvK4k= -github.com/cockroachdb/pebble v0.0.0-20230707145654-678f7e48216b/go.mod h1:FN5O47SBEz5+kO9fG8UTR64g2WS1u5ZFCgTvxGjoSks= +github.com/cockroachdb/pebble v0.0.0-20230707214756-fa85ec45a815 h1:qiUtzN39J+Wx2hAe91NkarLxb0Km59URdTe22y6fTPY= +github.com/cockroachdb/pebble v0.0.0-20230707214756-fa85ec45a815/go.mod h1:FN5O47SBEz5+kO9fG8UTR64g2WS1u5ZFCgTvxGjoSks= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 h1:DJK8W/iB+s/qkTtmXSrHA49lp5O3OsR7E6z4byOLy34= diff --git a/monitor.go b/monitor.go index 4bd5067..f7ce7d6 100644 --- a/monitor.go +++ b/monitor.go @@ -855,12 +855,22 @@ func (m *Monitor) SwitchService(srv int) error { if m.srv.Load() != int32(srv) { if m.lastNumber.Load() > 0 { // TODO record last block according to old service category - m.fs.Anchor(m.lastNumber.Load()) - m.fs.Flush() + switch m.srv.Load() { + case SRV_MODEL: + m.fs.Anchor(m.lastNumber.Load()) + m.fs.Flush() + case SRV_PRINT: + // TODO + } // TODO load last block according to new service category - m.fs.InitBlockNumber() - m.lastNumber.Store(m.fs.LastListenBlockNumber()) + switch srv { + case SRV_MODEL: + m.fs.InitBlockNumber() + m.lastNumber.Store(m.fs.LastListenBlockNumber()) + case SRV_PRINT: + // TODO + } } m.srv.Store(int32(srv)) log.Info("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) From f8a1310a7acd99786255636cce5840c4aacd4d69 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 19:56:28 +0800 Subject: [PATCH 08/17] Print service storage imp --- cmd/main.go | 3 +-- monitor.go | 60 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 1aaeea1..2569db6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -24,14 +24,13 @@ func main() { if m, err := robot.New(cfg, true, false, false, nil); err != nil { panic(err) } else { - m.SwitchService(robot.SRV_PRINT) - if err := m.Start(); err != nil { log.Error("start failed", "err", err) panic(err) } defer m.Stop() + m.SwitchService(robot.SRV_PRINT) /*go func() { for { m.SwitchService(robot.SRV_PRINT) diff --git a/monitor.go b/monitor.go index f7ce7d6..0707ad3 100644 --- a/monitor.go +++ b/monitor.go @@ -542,6 +542,7 @@ func (m *Monitor) Stop() { // log.Error("Monitor Fs Manager closed", "error", err) //} + // TODO dirty statics deal with if m.engine != nil { log.Info("Golang-kv engine close", "engine", m.engine.Name()) m.engine.Close() @@ -593,14 +594,16 @@ func (m *Monitor) run() error { } m.cl = rpcClient - m.lastNumber.Store(m.fs.LastListenBlockNumber()) + if m.srv.Load() == SRV_MODEL { + m.lastNumber.Store(m.fs.LastListenBlockNumber()) + if err := m.indexCheck(); err != nil { + return err + } + } + m.currentBlock() m.startNumber.Store(uint64(math.Min(float64(m.fs.LastListenBlockNumber()), float64(m.currentNumber.Load())))) // ? m.currentNumber:m.fs.LastListenBlockNumber - if err := m.indexCheck(); err != nil { - return err - } - //if err := m.loadHistory(); err != nil { // return err //} @@ -782,6 +785,7 @@ func (m *Monitor) syncLastBlock() uint64 { // batch blocks operation according service category for _, rpcBlock := range blocks { if err := m.solve(rpcBlock); err != nil { + log.Error("solve err", "err", err) m.lastNumber.Store(i - 1) return 0 } @@ -808,6 +812,7 @@ func (m *Monitor) syncLastBlock() uint64 { return 0 } if err := m.solve(rpcBlock); err != nil { + log.Error("solve err", "err", err) m.lastNumber.Store(i - 1) return 0 } @@ -853,27 +858,38 @@ func (m *Monitor) solve(block *types.Block) error { func (m *Monitor) SwitchService(srv int) error { if m.srv.Load() != int32(srv) { - if m.lastNumber.Load() > 0 { - // TODO record last block according to old service category - switch m.srv.Load() { - case SRV_MODEL: + //if m.lastNumber.Load() > 0 { + // TODO record last block according to old service category + switch m.srv.Load() { + case SRV_MODEL: + if m.lastNumber.Load() > 0 { m.fs.Anchor(m.lastNumber.Load()) m.fs.Flush() - case SRV_PRINT: - // TODO } + case SRV_PRINT: + if m.lastNumber.Load() > 0 { + m.engine.Set([]byte("srv_print_last"), []byte(strconv.FormatUint(m.lastNumber.Load(), 16))) + } + } - // TODO load last block according to new service category - switch srv { - case SRV_MODEL: - m.fs.InitBlockNumber() - m.lastNumber.Store(m.fs.LastListenBlockNumber()) - case SRV_PRINT: - // TODO + // TODO load last block according to new service category + switch srv { + case SRV_MODEL: + m.fs.InitBlockNumber() + m.lastNumber.Store(m.fs.LastListenBlockNumber()) + case SRV_PRINT: + if v := m.engine.Get([]byte("srv_print_last")); v != nil { + + number, err := strconv.ParseUint(string(v), 16, 64) + if err != nil { + return err + } + m.lastNumber.Store(number) } } + //} m.srv.Store(int32(srv)) - log.Info("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) + log.Info("Service switch", "srv", m.srv.Load(), "srv_print_last", m.lastNumber.Load()) } return nil } @@ -888,7 +904,7 @@ func (m *Monitor) forExchangeService(block *types.Block) error { } func (m *Monitor) forPrintService(block *types.Block) error { - log.Info("Block print", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs)) + log.Info("Block print", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs), "last", m.lastNumber.Load()) if len(block.Txs) > 0 { for _, t := range block.Txs { x := new(big.Float).Quo(new(big.Float).SetInt(t.Amount), new(big.Float).SetInt(big.NewInt(params1.Cortex))) @@ -907,7 +923,9 @@ func (m *Monitor) forPrintService(block *types.Block) error { } else { m.engine.Set(block.Hash.Bytes(), v) } - m.fs.Anchor(block.Number) + + m.lastNumber.Store(block.Number) + m.engine.Set([]byte("srv_print_last"), []byte(strconv.FormatUint(block.Number, 16))) return nil } From ec46dcaa04aff016cbcc70021e605e60f3126979 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 20:04:59 +0800 Subject: [PATCH 09/17] rename record service --- cmd/main.go | 4 ++-- doc.go | 4 ++-- monitor.go | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 2569db6..62a6ebd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -30,10 +30,10 @@ func main() { } defer m.Stop() - m.SwitchService(robot.SRV_PRINT) + m.SwitchService(robot.SRV_RECORD) /*go func() { for { - m.SwitchService(robot.SRV_PRINT) + m.SwitchService(robot.SRV_RECORD) time.Sleep(5 * time.Second) m.SwitchService(robot.SRV_MODEL) time.Sleep(5 * time.Second) diff --git a/doc.go b/doc.go index b0a0514..0f8c0bd 100644 --- a/doc.go +++ b/doc.go @@ -17,6 +17,6 @@ package robot const ( - SRV_MODEL = 0 - SRV_PRINT = 99 + SRV_MODEL = 0 + SRV_RECORD = 99 ) diff --git a/monitor.go b/monitor.go index 0707ad3..ace9f37 100644 --- a/monitor.go +++ b/monitor.go @@ -849,7 +849,7 @@ func (m *Monitor) solve(block *types.Block) error { // return m.forExplorerService(block) // others service, explorer, exchange, zkp, nft, etc. //case 2: // return m.forExchangeService(block) - case SRV_PRINT: + case SRV_RECORD: return m.forPrintService(block) default: return errors.New("no block operation service found") @@ -866,9 +866,9 @@ func (m *Monitor) SwitchService(srv int) error { m.fs.Anchor(m.lastNumber.Load()) m.fs.Flush() } - case SRV_PRINT: + case SRV_RECORD: if m.lastNumber.Load() > 0 { - m.engine.Set([]byte("srv_print_last"), []byte(strconv.FormatUint(m.lastNumber.Load(), 16))) + m.engine.Set([]byte("srv_record_last"), []byte(strconv.FormatUint(m.lastNumber.Load(), 16))) } } @@ -877,8 +877,8 @@ func (m *Monitor) SwitchService(srv int) error { case SRV_MODEL: m.fs.InitBlockNumber() m.lastNumber.Store(m.fs.LastListenBlockNumber()) - case SRV_PRINT: - if v := m.engine.Get([]byte("srv_print_last")); v != nil { + case SRV_RECORD: + if v := m.engine.Get([]byte("srv_record_last")); v != nil { number, err := strconv.ParseUint(string(v), 16, 64) if err != nil { @@ -889,7 +889,7 @@ func (m *Monitor) SwitchService(srv int) error { } //} m.srv.Store(int32(srv)) - log.Info("Service switch", "srv", m.srv.Load(), "srv_print_last", m.lastNumber.Load()) + log.Info("Service switch", "srv", m.srv.Load(), "srv_record_last", m.lastNumber.Load()) } return nil } @@ -904,11 +904,11 @@ func (m *Monitor) forExchangeService(block *types.Block) error { } func (m *Monitor) forPrintService(block *types.Block) error { - log.Info("Block print", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs), "last", m.lastNumber.Load()) + log.Info("Block record", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs), "last", m.lastNumber.Load()) if len(block.Txs) > 0 { for _, t := range block.Txs { x := new(big.Float).Quo(new(big.Float).SetInt(t.Amount), new(big.Float).SetInt(big.NewInt(params1.Cortex))) - log.Info("Tx print", "hash", t.Hash, "amount", x, "gas", t.GasLimit, "receipt", t.Recipient, "payload", t.Payload) + log.Info("Tx record", "hash", t.Hash, "amount", x, "gas", t.GasLimit, "receipt", t.Recipient, "payload", t.Payload) if v, err := json.Marshal(t); err != nil { return err @@ -925,7 +925,7 @@ func (m *Monitor) forPrintService(block *types.Block) error { } m.lastNumber.Store(block.Number) - m.engine.Set([]byte("srv_print_last"), []byte(strconv.FormatUint(block.Number, 16))) + m.engine.Set([]byte("srv_record_last"), []byte(strconv.FormatUint(block.Number, 16))) return nil } From 4ca76f3b12aabc0a2253a24ffd51faca365165fe Mon Sep 17 00:00:00 2001 From: ucwong Date: Sat, 8 Jul 2023 21:54:20 +0800 Subject: [PATCH 10/17] last num in memory fix --- cmd/main.go | 12 ++++++------ monitor.go | 22 +++++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 62a6ebd..852f553 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,7 +4,7 @@ import ( "os" "os/signal" "syscall" - //"time" + "time" "github.com/CortexFoundation/CortexTheseus/log" "github.com/CortexFoundation/robot" @@ -30,15 +30,15 @@ func main() { } defer m.Stop() - m.SwitchService(robot.SRV_RECORD) - /*go func() { + //m.SwitchService(robot.SRV_RECORD) + go func() { for { m.SwitchService(robot.SRV_RECORD) - time.Sleep(5 * time.Second) + time.Sleep(10 * time.Second) m.SwitchService(robot.SRV_MODEL) - time.Sleep(5 * time.Second) + time.Sleep(10 * time.Second) } - }()*/ + }() var c = make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) diff --git a/monitor.go b/monitor.go index ace9f37..04b242f 100644 --- a/monitor.go +++ b/monitor.go @@ -804,7 +804,6 @@ func (m *Monitor) syncLastBlock() uint64 { }*/ } } else { - rpcBlock, rpcErr := m.rpcBlockByNumber(i) if rpcErr != nil { log.Error("Sync old block failed", "number", i, "error", rpcErr) @@ -831,7 +830,8 @@ func (m *Monitor) syncLastBlock() uint64 { }*/ } } - m.lastNumber.Store(maxNumber) + //m.lastNumber.Store(maxNumber) + m.storeLastNumber(maxNumber) //if maxNumber-minNumber > batch-1 { if maxNumber-minNumber > delay { elapsedA := time.Duration(mclock.Now()) - time.Duration(m.start) @@ -865,9 +865,11 @@ func (m *Monitor) SwitchService(srv int) error { if m.lastNumber.Load() > 0 { m.fs.Anchor(m.lastNumber.Load()) m.fs.Flush() + log.Info("Model srv flush", "last", m.lastNumber.Load()) } case SRV_RECORD: if m.lastNumber.Load() > 0 { + log.Info("Record srv flush", "last", m.lastNumber.Load()) m.engine.Set([]byte("srv_record_last"), []byte(strconv.FormatUint(m.lastNumber.Load(), 16))) } } @@ -877,23 +879,29 @@ func (m *Monitor) SwitchService(srv int) error { case SRV_MODEL: m.fs.InitBlockNumber() m.lastNumber.Store(m.fs.LastListenBlockNumber()) + log.Info("Model srv load", "last", m.lastNumber.Load()) case SRV_RECORD: if v := m.engine.Get([]byte("srv_record_last")); v != nil { - number, err := strconv.ParseUint(string(v), 16, 64) if err != nil { return err } m.lastNumber.Store(number) } + log.Info("Record srv load", "last", m.lastNumber.Load()) } //} m.srv.Store(int32(srv)) - log.Info("Service switch", "srv", m.srv.Load(), "srv_record_last", m.lastNumber.Load()) + log.Debug("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) } return nil } +func (m *Monitor) storeLastNumber(last uint64) { + log.Info("Last number changed", "last", last) + m.lastNumber.Store(last) +} + // only for examples func (m *Monitor) forExplorerService(block *types.Block) error { return errors.New("not support") @@ -904,11 +912,11 @@ func (m *Monitor) forExchangeService(block *types.Block) error { } func (m *Monitor) forPrintService(block *types.Block) error { - log.Info("Block record", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs), "last", m.lastNumber.Load()) + log.Debug("Block record", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs), "last", m.lastNumber.Load()) if len(block.Txs) > 0 { for _, t := range block.Txs { x := new(big.Float).Quo(new(big.Float).SetInt(t.Amount), new(big.Float).SetInt(big.NewInt(params1.Cortex))) - log.Info("Tx record", "hash", t.Hash, "amount", x, "gas", t.GasLimit, "receipt", t.Recipient, "payload", t.Payload) + log.Debug("Tx record", "hash", t.Hash, "amount", x, "gas", t.GasLimit, "receipt", t.Recipient, "payload", t.Payload) if v, err := json.Marshal(t); err != nil { return err @@ -924,8 +932,8 @@ func (m *Monitor) forPrintService(block *types.Block) error { m.engine.Set(block.Hash.Bytes(), v) } - m.lastNumber.Store(block.Number) m.engine.Set([]byte("srv_record_last"), []byte(strconv.FormatUint(block.Number, 16))) + //m.lastNumber.Store(block.Number) return nil } From c01189060930c7c9630ec2e9986dfe4d8711ae56 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 03:01:12 +0800 Subject: [PATCH 11/17] service switch fix --- cmd/main.go | 7 ++--- monitor.go | 77 +++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 852f553..fcd5902 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -33,10 +33,11 @@ func main() { //m.SwitchService(robot.SRV_RECORD) go func() { for { - m.SwitchService(robot.SRV_RECORD) - time.Sleep(10 * time.Second) + //m.SwitchService(robot.SRV_RECORD) + time.Sleep(30 * time.Second) m.SwitchService(robot.SRV_MODEL) - time.Sleep(10 * time.Second) + time.Sleep(30 * time.Second) + m.SwitchService(robot.SRV_RECORD) } }() diff --git a/monitor.go b/monitor.go index 04b242f..da74a0b 100644 --- a/monitor.go +++ b/monitor.go @@ -63,7 +63,9 @@ type Monitor struct { engine kv.Bucket //dl *backend.TorrentManager - exitCh chan any + exitCh chan any + srvCh chan int + //exitSyncCh chan any terminated atomic.Bool lastNumber atomic.Uint64 startNumber atomic.Uint64 @@ -119,7 +121,9 @@ func New(flag *params.Config, cache, compress, listen bool, callback chan any) ( //fs: fs, //dl: tMana, exitCh: make(chan any), - scope: uint64(math.Min(float64(runtime.NumCPU()), float64(8))), + srvCh: make(chan int), + //exitSyncCh: make(chan any), + scope: uint64(math.Min(float64(runtime.NumCPU()), float64(8))), //taskCh: make(chan *types.Block, batch), //start: mclock.Now(), } @@ -513,6 +517,13 @@ func (m *Monitor) parseBlockTorrentInfo(b *types.Block) (bool, error) { func (m *Monitor) exit() { m.closeOnce.Do(func() { + /*if m.exitSyncCh != nil { + close(m.exitSyncCh) + m.exitSyncCh = nil + } else { + log.Warn("Listener sync has already been stopped") + }*/ + if m.exitCh != nil { close(m.exitCh) m.wg.Wait() @@ -562,16 +573,21 @@ func (m *Monitor) Start() error { //return nil //} + s := make(chan bool) m.startOnce.Do(func() { m.wg.Add(1) go func() { defer m.wg.Done() + defer func() { + s <- true + }() m.fs.Init() if err := m.run(); err != nil { log.Error("Fs monitor start failed", "err", err) } }() }) + <-s return nil } @@ -644,6 +660,10 @@ func (m *Monitor) syncLatestBlock() { progress, counter, end := uint64(0), 0, false for { select { + case sv := <-m.srvCh: + //log.Info("Do switch start", "srv", sv) + m.DoSwitch(sv) + //log.Info("Do switch finish", "srv", sv) case <-timer.C: //m.currentBlock() progress = m.syncLastBlock() @@ -740,6 +760,7 @@ func (m *Monitor) syncLastBlock() uint64 { } minNumber := m.lastNumber.Load() + 1 + //log.Info("min", "minNumber", minNumber) maxNumber := uint64(0) if currentNumber > delay { maxNumber = currentNumber - delay @@ -751,23 +772,27 @@ func (m *Monitor) syncLastBlock() uint64 { } } - if maxNumber > batch*8+minNumber { - maxNumber = minNumber + batch*8 + if maxNumber > batch+minNumber { + maxNumber = minNumber + batch } + if maxNumber < minNumber { return 0 } + if m.start == 0 { m.start = mclock.Now() } - //start := mclock.Now() + for i := minNumber; i <= maxNumber; { // i++ { if m.terminated.Load() { log.Warn("Fs scan terminated", "number", i) maxNumber = i - 1 break } - + if maxNumber > minNumber && i%99 == 0 { + log.Info("Running", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch, "i", i, "srv", m.srv.Load(), "size", maxNumber-minNumber, "progress", float64(i-minNumber)/float64(maxNumber-minNumber)) + } if m.ckp != nil && m.skip(i) { //m.lastNumber = i - 1 i++ @@ -830,8 +855,9 @@ func (m *Monitor) syncLastBlock() uint64 { }*/ } } - //m.lastNumber.Store(maxNumber) - m.storeLastNumber(maxNumber) + log.Info("Last number changed", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch) + m.lastNumber.Store(maxNumber) + //m.storeLastNumber(maxNumber) //if maxNumber-minNumber > batch-1 { if maxNumber-minNumber > delay { elapsedA := time.Duration(mclock.Now()) - time.Duration(m.start) @@ -857,18 +883,32 @@ func (m *Monitor) solve(block *types.Block) error { } func (m *Monitor) SwitchService(srv int) error { + //log.Info("Srv start", "srv", srv, "ch", cap(m.srvCh)) + //if cap(m.srvCh) == 0 { + m.srvCh <- srv + //} else { + // return errors.New("can't switch service right now") + //} + //log.Info("Srv end", "srv", srv, "ch", cap(m.srvCh)) + return nil +} +func (m *Monitor) DoSwitch(srv int) error { if m.srv.Load() != int32(srv) { //if m.lastNumber.Load() > 0 { // TODO record last block according to old service category switch m.srv.Load() { case SRV_MODEL: if m.lastNumber.Load() > 0 { + //close(m.exitSyncCh) + m.fs.Anchor(m.lastNumber.Load()) m.fs.Flush() log.Info("Model srv flush", "last", m.lastNumber.Load()) } case SRV_RECORD: if m.lastNumber.Load() > 0 { + //close(m.exitSyncCh) + log.Info("Record srv flush", "last", m.lastNumber.Load()) m.engine.Set([]byte("srv_record_last"), []byte(strconv.FormatUint(m.lastNumber.Load(), 16))) } @@ -880,19 +920,29 @@ func (m *Monitor) SwitchService(srv int) error { m.fs.InitBlockNumber() m.lastNumber.Store(m.fs.LastListenBlockNumber()) log.Info("Model srv load", "last", m.lastNumber.Load()) + + //m.exitSyncCh = make(chan any) + //m.wg.Add(1) + //go m.syncLatestBlock() case SRV_RECORD: if v := m.engine.Get([]byte("srv_record_last")); v != nil { - number, err := strconv.ParseUint(string(v), 16, 64) - if err != nil { - return err + if number, err := strconv.ParseUint(string(v), 16, 64); err == nil { + m.lastNumber.Store(number) + } else { + m.lastNumber.Store(0) } - m.lastNumber.Store(number) + } else { + m.lastNumber.Store(0) } log.Info("Record srv load", "last", m.lastNumber.Load()) + + //m.exitSyncCh = make(chan any) + //m.wg.Add(1) + //go m.syncLatestBlock() } //} m.srv.Store(int32(srv)) - log.Debug("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) + log.Info("Service switch", "srv", m.srv.Load(), "last", m.lastNumber.Load()) } return nil } @@ -933,7 +983,6 @@ func (m *Monitor) forPrintService(block *types.Block) error { } m.engine.Set([]byte("srv_record_last"), []byte(strconv.FormatUint(block.Number, 16))) - //m.lastNumber.Store(block.Number) return nil } From 3644e83fe3beb0113b7008f03427cb6f48308b47 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 03:13:28 +0800 Subject: [PATCH 12/17] tiny fix --- monitor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.go b/monitor.go index da74a0b..d1c7fe3 100644 --- a/monitor.go +++ b/monitor.go @@ -790,7 +790,7 @@ func (m *Monitor) syncLastBlock() uint64 { maxNumber = i - 1 break } - if maxNumber > minNumber && i%99 == 0 { + if maxNumber > minNumber && (i-minNumber)%128 == 0 { log.Info("Running", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch, "i", i, "srv", m.srv.Load(), "size", maxNumber-minNumber, "progress", float64(i-minNumber)/float64(maxNumber-minNumber)) } if m.ckp != nil && m.skip(i) { From 629142db43725a0af6d8e934e17974cbb1f85fe0 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 04:28:09 +0800 Subject: [PATCH 13/17] params fix --- cmd/main.go | 4 ++-- monitor.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index fcd5902..41790db 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -35,9 +35,9 @@ func main() { for { //m.SwitchService(robot.SRV_RECORD) time.Sleep(30 * time.Second) - m.SwitchService(robot.SRV_MODEL) + //m.SwitchService(robot.SRV_MODEL) time.Sleep(30 * time.Second) - m.SwitchService(robot.SRV_RECORD) + //m.SwitchService(robot.SRV_RECORD) } }() diff --git a/monitor.go b/monitor.go index d1c7fe3..2e22203 100644 --- a/monitor.go +++ b/monitor.go @@ -43,8 +43,8 @@ import ( ) const ( - batch = params.SyncBatch - delay = params.Delay + batch = 4096 //params.SyncBatch + delay = 6 //params.Delay ) var ( @@ -670,7 +670,7 @@ func (m *Monitor) syncLatestBlock() { // Avoid sync in full mode, fresh interval may be less. if progress >= delay { end = false - timer.Reset(time.Millisecond * 1000) + timer.Reset(time.Millisecond * 0) } else if progress > 1 { end = false timer.Reset(time.Millisecond * 2000) @@ -698,7 +698,7 @@ func (m *Monitor) syncLatestBlock() { timer.Reset(time.Millisecond * 6750) } counter++ - if counter%10 == 0 { + if counter%100 == 0 { log.Info("Monitor status", "blocks", progress, "current", m.CurrentNumber(), "latest", m.lastNumber.Load(), "end", end, "txs", m.fs.Txs(), "ckp", m.fs.CheckPoint(), "last", m.fs.LastListenBlockNumber()) counter = 0 } @@ -791,7 +791,7 @@ func (m *Monitor) syncLastBlock() uint64 { break } if maxNumber > minNumber && (i-minNumber)%128 == 0 { - log.Info("Running", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch, "i", i, "srv", m.srv.Load(), "size", maxNumber-minNumber, "progress", float64(i-minNumber)/float64(maxNumber-minNumber)) + log.Debug("Running", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch, "i", i, "srv", m.srv.Load(), "size", maxNumber-minNumber, "progress", float64(i-minNumber)/float64(maxNumber-minNumber)) } if m.ckp != nil && m.skip(i) { //m.lastNumber = i - 1 @@ -855,7 +855,7 @@ func (m *Monitor) syncLastBlock() uint64 { }*/ } } - log.Info("Last number changed", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch) + log.Debug("Last number changed", "min", minNumber, "max", maxNumber, "cur", currentNumber, "last", m.lastNumber.Load(), "batch", batch) m.lastNumber.Store(maxNumber) //m.storeLastNumber(maxNumber) //if maxNumber-minNumber > batch-1 { From 6e7db2cdc66d6615deb1e57e6c81486851ac9448 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 04:47:56 +0800 Subject: [PATCH 14/17] fix --- cmd/main.go | 4 ++-- monitor.go | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 41790db..3255cc6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -33,9 +33,9 @@ func main() { //m.SwitchService(robot.SRV_RECORD) go func() { for { - //m.SwitchService(robot.SRV_RECORD) + m.SwitchService(robot.SRV_RECORD) time.Sleep(30 * time.Second) - //m.SwitchService(robot.SRV_MODEL) + m.SwitchService(robot.SRV_MODEL) time.Sleep(30 * time.Second) //m.SwitchService(robot.SRV_RECORD) } diff --git a/monitor.go b/monitor.go index 2e22203..384d115 100644 --- a/monitor.go +++ b/monitor.go @@ -573,21 +573,16 @@ func (m *Monitor) Start() error { //return nil //} - s := make(chan bool) m.startOnce.Do(func() { m.wg.Add(1) go func() { defer m.wg.Done() - defer func() { - s <- true - }() m.fs.Init() if err := m.run(); err != nil { log.Error("Fs monitor start failed", "err", err) } }() }) - <-s return nil } From cf3bf2694e7784329fc001d6f681df4ec5f8d421 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 17:03:10 +0800 Subject: [PATCH 15/17] typo --- monitor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.go b/monitor.go index 384d115..f65df72 100644 --- a/monitor.go +++ b/monitor.go @@ -871,7 +871,7 @@ func (m *Monitor) solve(block *types.Block) error { //case 2: // return m.forExchangeService(block) case SRV_RECORD: - return m.forPrintService(block) + return m.forRecordService(block) default: return errors.New("no block operation service found") } @@ -956,7 +956,7 @@ func (m *Monitor) forExchangeService(block *types.Block) error { return errors.New("not support") } -func (m *Monitor) forPrintService(block *types.Block) error { +func (m *Monitor) forRecordService(block *types.Block) error { log.Debug("Block record", "num", block.Number, "hash", block.Hash, "txs", len(block.Txs), "last", m.lastNumber.Load()) if len(block.Txs) > 0 { for _, t := range block.Txs { From 04e0a415e52087fc0da510170fe853edec6ed97a Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 17:13:54 +0800 Subject: [PATCH 16/17] exit channel --- monitor.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/monitor.go b/monitor.go index f65df72..ae86962 100644 --- a/monitor.go +++ b/monitor.go @@ -880,7 +880,11 @@ func (m *Monitor) solve(block *types.Block) error { func (m *Monitor) SwitchService(srv int) error { //log.Info("Srv start", "srv", srv, "ch", cap(m.srvCh)) //if cap(m.srvCh) == 0 { - m.srvCh <- srv + select { + case m.srvCh <- srv: + case <-m.exitCh: + return nil + } //} else { // return errors.New("can't switch service right now") //} From dc9ac0275184547e31a812d6a9a4c69bb996fe09 Mon Sep 17 00:00:00 2001 From: ucwong Date: Sun, 9 Jul 2023 17:38:05 +0800 Subject: [PATCH 17/17] doSwitch --- monitor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.go b/monitor.go index ae86962..7081a18 100644 --- a/monitor.go +++ b/monitor.go @@ -657,7 +657,7 @@ func (m *Monitor) syncLatestBlock() { select { case sv := <-m.srvCh: //log.Info("Do switch start", "srv", sv) - m.DoSwitch(sv) + m.doSwitch(sv) //log.Info("Do switch finish", "srv", sv) case <-timer.C: //m.currentBlock() @@ -891,7 +891,7 @@ func (m *Monitor) SwitchService(srv int) error { //log.Info("Srv end", "srv", srv, "ch", cap(m.srvCh)) return nil } -func (m *Monitor) DoSwitch(srv int) error { +func (m *Monitor) doSwitch(srv int) error { if m.srv.Load() != int32(srv) { //if m.lastNumber.Load() > 0 { // TODO record last block according to old service category