github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/swarm/storage/common.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 12:09:49</date> 10 //</624342680536616960> 11 12 // 13 // 14 // 15 // 16 // 17 // 18 // 19 // 20 // 21 // 22 // 23 // 24 // 25 // 26 // 27 package storage 28 29 import ( 30 "context" 31 "sync" 32 33 "github.com/ethereum/go-ethereum/swarm/log" 34 ) 35 36 // 37 // 38 // 39 func PutChunks(store *LocalStore, chunks ...*Chunk) { 40 wg := sync.WaitGroup{} 41 wg.Add(len(chunks)) 42 go func() { 43 for _, c := range chunks { 44 <-c.dbStoredC 45 if err := c.GetErrored(); err != nil { 46 log.Error("chunk store fail", "err", err, "key", c.Addr) 47 } 48 wg.Done() 49 } 50 }() 51 for _, c := range chunks { 52 go store.Put(context.TODO(), c) 53 } 54 wg.Wait() 55 } 56