mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
More logging with fmt package
This commit is contained in:
parent
eae4473a81
commit
82e24a488d
4 changed files with 40 additions and 15 deletions
|
|
@ -19,6 +19,7 @@ package stream
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
|
@ -172,9 +173,9 @@ R:
|
||||||
for req := range d.receiveC {
|
for req := range d.receiveC {
|
||||||
// this should be has locally
|
// this should be has locally
|
||||||
chunk, err := d.db.Get(req.Key)
|
chunk, err := d.db.Get(req.Key)
|
||||||
log.Error("pick from receiveC", "chunk", chunk.Key.Hex(), "reqC", chunk.ReqC, "err", err)
|
fmt.Fprintln(os.Stderr, "pick from receiveC", "chunk", chunk.Key.Hex(), "reqC", chunk.ReqC, "err", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Error("found existing?", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, "found existing?", "hash", chunk.Key.Hex())
|
||||||
continue R
|
continue R
|
||||||
}
|
}
|
||||||
if err != storage.ErrFetching {
|
if err != storage.ErrFetching {
|
||||||
|
|
@ -182,19 +183,19 @@ R:
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-chunk.ReqC:
|
case <-chunk.ReqC:
|
||||||
log.Error("someone else delivered?", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, "someone else delivered?", "hash", chunk.Key.Hex())
|
||||||
continue R
|
continue R
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
chunk.SData = req.SData
|
chunk.SData = req.SData
|
||||||
log.Error("received delivery", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, "received delivery", "hash", chunk.Key.Hex())
|
||||||
d.db.Put(chunk)
|
d.db.Put(chunk)
|
||||||
log.Error("put to db", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, "put to db", "hash", chunk.Key.Hex())
|
||||||
chunk.WaitToStore()
|
chunk.WaitToStore()
|
||||||
close(chunk.ReqC)
|
close(chunk.ReqC)
|
||||||
//log.Warn("received delivery stored", "hash", chunk.Key)
|
//log.Warn("received delivery stored", "hash", chunk.Key)
|
||||||
log.Error("requesters notified", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, "requesters notified", "hash", chunk.Key.Hex())
|
||||||
d.counterDone++
|
d.counterDone++
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"runtime/debug"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ func testSyncBetweenNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
|
||||||
} else if err == nil {
|
} else if err == nil {
|
||||||
nodeHashFound++
|
nodeHashFound++
|
||||||
} else {
|
} else {
|
||||||
log.Error("not found", "index", i, "origin", j, "key", key.Hex(), "err", err)
|
fmt.Fprintln(os.Stderr, time.Now(), "not found", "index", i, "origin", j, "key", key.Hex(), "err", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +211,7 @@ func testSyncBetweenNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
startedAt := time.Now()
|
startedAt := time.Now()
|
||||||
timeout := 4 * time.Second
|
timeout := 30 * time.Second
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
result, err := sim.Run(ctx, conf)
|
result, err := sim.Run(ctx, conf)
|
||||||
|
|
@ -222,6 +222,5 @@ func testSyncBetweenNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
t.Fatalf("Simulation failed: %s", result.Error)
|
t.Fatalf("Simulation failed: %s", result.Error)
|
||||||
streamTesting.CheckResult(t, result, startedAt, finishedAt)
|
streamTesting.CheckResult(t, result, startedAt, finishedAt)
|
||||||
debug.PrintStack()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
|
@ -538,8 +540,22 @@ func (s *DbStore) CurrentStorageIndex() uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DbStore) Put(chunk *Chunk) {
|
func (s *DbStore) Put(chunk *Chunk) {
|
||||||
log.Error("DbStore.Put", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put", "hash", chunk.Key.Hex())
|
||||||
|
done := make(chan struct{})
|
||||||
|
defer close(done)
|
||||||
|
go func() {
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put WAITER STARTED", "hash", chunk.Key.Hex())
|
||||||
|
select {
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put WAITING", "hash", chunk.Key.Hex())
|
||||||
|
case <-done:
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put EXITED", "hash", chunk.Key.Hex())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.LOCK acquiring", "hash", chunk.Key.Hex())
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.LOCK acquired", "hash", chunk.Key.Hex())
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
||||||
ikey := getIndexKey(chunk.Key)
|
ikey := getIndexKey(chunk.Key)
|
||||||
|
|
@ -548,19 +564,26 @@ func (s *DbStore) Put(chunk *Chunk) {
|
||||||
po := s.po(chunk.Key)
|
po := s.po(chunk.Key)
|
||||||
|
|
||||||
idata, err := s.db.Get(ikey)
|
idata, err := s.db.Get(ikey)
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.db.Get", "hash", chunk.Key.Hex(), "err", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.doPut(chunk, ikey, &index, po)
|
s.doPut(chunk, ikey, &index, po)
|
||||||
batchC := s.batchC
|
batchC := s.batchC
|
||||||
go func() {
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put PANIC", "hash", chunk.Key.Hex(), "err", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
<-batchC
|
<-batchC
|
||||||
close(chunk.dbStored)
|
close(chunk.dbStored)
|
||||||
}()
|
}()
|
||||||
log.Error("DbStore.Put doPut", "hash", chunk.Key.Hex(), "dataIdx", s.dataIdx)
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put doPut", "hash", chunk.Key.Hex(), "dataIdx", s.dataIdx)
|
||||||
} else {
|
} else {
|
||||||
log.Trace(fmt.Sprintf("DbStore: chunk already exists, only update access"))
|
log.Trace(fmt.Sprintf("DbStore: chunk already exists, only update access"))
|
||||||
decodeIndex(idata, &index)
|
decodeIndex(idata, &index)
|
||||||
close(chunk.dbStored)
|
close(chunk.dbStored)
|
||||||
log.Error("DbStore.Put already found", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "DbStore.Put already found", "hash", chunk.Key.Hex())
|
||||||
}
|
}
|
||||||
index.Access = s.accessCnt
|
index.Access = s.accessCnt
|
||||||
s.accessCnt++
|
s.accessCnt++
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@ package storage
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/swarm/storage/mock"
|
"github.com/ethereum/go-ethereum/swarm/storage/mock"
|
||||||
|
|
@ -96,9 +98,9 @@ func NewTestLocalStoreForAddr(path string, basekey []byte) (*LocalStore, error)
|
||||||
func (self *LocalStore) Put(chunk *Chunk) {
|
func (self *LocalStore) Put(chunk *Chunk) {
|
||||||
chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8]))
|
chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8]))
|
||||||
self.memStore.Put(chunk)
|
self.memStore.Put(chunk)
|
||||||
log.Error("put to memstore", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "put to memstore", "hash", chunk.Key.Hex())
|
||||||
self.DbStore.Put(chunk)
|
self.DbStore.Put(chunk)
|
||||||
log.Error("put to dbstore", "hash", chunk.Key.Hex())
|
fmt.Fprintln(os.Stderr, time.Now(), "put to dbstore", "hash", chunk.Key.Hex())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get(chunk *Chunk) looks up a chunk in the local stores
|
// Get(chunk *Chunk) looks up a chunk in the local stores
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue