copernet / copernicus

An alternative implementation of the Bitcoin Cash protocol, written in Golang
https://copernet.io
BSD 2-Clause "Simplified" License
85 stars 34 forks source link

Try to read not exists block data during activateBestChain #206

Closed whunmr closed 5 years ago

whunmr commented 5 years ago

Describe the bug lots logs seems try to read block at invalid position (File=-1, Pos=0)

To Reproduce running latest code in the master

Expected behavior not try to read block data if block data has has not been downloaded yet.

Additional context

2018/12/05 10:01:41.147 [E] [disk.go:229]  ReadBlockFromDisk: OpenBlockFile failed for BlcokDiskPos(File=-1, Pos=0)
2018/12/05 10:01:41.147 [E] [lchain.go:242]  error: FailedToReadBlock: false
2018/12/05 10:01:41.147 [E] [blockservice.go:99]   ActivateBestChain failed :module: disk, errcode: 5006: FailedToReadBlock
2018/12/05 10:01:41.147 [E] [syncmanager.go:619]  ProcessBlockCallBack err:module: disk, errcode: 5006: FailedToReadBlock, hash: 0000000000000000297a83beef2cf9bffd83fb9080c1a5236d1cb1746ca54c0e
2018/12/05 10:01:41.254 [E] [disk.go:229]  ReadBlockFromDisk: OpenBlockFile failed for BlcokDiskPos(File=-1, Pos=0)
2018/12/05 10:01:41.254 [E] [lchain.go:242]  error: FailedToReadBlock: false
2018/12/05 10:01:41.254 [E] [blockservice.go:99]   ActivateBestChain failed :module: disk, errcode: 5006: FailedToReadBlock
2018/12/05 10:01:41.254 [E] [syncmanager.go:619]  ProcessBlockCallBack err:module: disk, errcode: 5006: FailedToReadBlock, hash: 00000000000000007c2a14250b43a28843f1c301bbbc4e4af6aa25cc8942cf0c
2018/12/05 10:01:41.328 [E] [disk.go:229]  ReadBlockFromDisk: OpenBlockFile failed for BlcokDiskPos(File=-1, Pos=0)
2018/12/05 10:01:41.328 [E] [lchain.go:242]  error: FailedToReadBlock: false
2018/12/05 10:01:41.328 [E] [blockservice.go:99]   ActivateBestChain failed :module: disk, errcode: 5006: FailedToReadBlock
whunmr commented 5 years ago

fixed in https://github.com/copernet/copernicus/commit/9319ffe8900c61f5ce76248f1a2d6d3955df71a2