github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/swarm/fuse/swarmfs.go (about) 1 2 //此源码被清华学神尹成大魔王专业翻译分析并修改 3 //尹成QQ77025077 4 //尹成微信18510341407 5 //尹成所在QQ群721929980 6 //尹成邮箱 yinc13@mails.tsinghua.edu.cn 7 //尹成毕业于清华大学,微软区块链领域全球最有价值专家 8 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 9 // 10 // 11 // 12 // 13 // 14 // 15 // 16 // 17 // 18 // 19 // 20 // 21 // 22 // 23 // 24 25 package fuse 26 27 import ( 28 "sync" 29 "time" 30 31 "github.com/ethereum/go-ethereum/swarm/api" 32 ) 33 34 const ( 35 Swarmfs_Version = "0.1" 36 mountTimeout = time.Second * 5 37 unmountTimeout = time.Second * 10 38 maxFuseMounts = 5 39 ) 40 41 var ( 42 swarmfs *SwarmFS // 43 swarmfsLock sync.Once 44 45 inode uint64 = 1 // 46 inodeLock sync.RWMutex 47 ) 48 49 type SwarmFS struct { 50 swarmApi *api.API 51 activeMounts map[string]*MountInfo 52 swarmFsLock *sync.RWMutex 53 } 54 55 func NewSwarmFS(api *api.API) *SwarmFS { 56 swarmfsLock.Do(func() { 57 swarmfs = &SwarmFS{ 58 swarmApi: api, 59 swarmFsLock: &sync.RWMutex{}, 60 activeMounts: map[string]*MountInfo{}, 61 } 62 }) 63 return swarmfs 64 65 } 66 67 // 68 func NewInode() uint64 { 69 inodeLock.Lock() 70 defer inodeLock.Unlock() 71 inode += 1 72 return inode 73 }