github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/swarm/fuse/swarmfs.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:47</date>
    10  //</624342671179124736>
    11  
    12  //
    13  //
    14  //
    15  //
    16  //
    17  //
    18  //
    19  //
    20  //
    21  //
    22  //
    23  //
    24  //
    25  //
    26  //
    27  
    28  package fuse
    29  
    30  import (
    31  	"sync"
    32  	"time"
    33  
    34  	"github.com/ethereum/go-ethereum/swarm/api"
    35  )
    36  
    37  const (
    38  	Swarmfs_Version = "0.1"
    39  	mountTimeout    = time.Second * 5
    40  	unmountTimeout  = time.Second * 10
    41  	maxFuseMounts   = 5
    42  )
    43  
    44  var (
    45  swarmfs     *SwarmFS //
    46  	swarmfsLock sync.Once
    47  
    48  inode     uint64 = 1 //
    49  	inodeLock sync.RWMutex
    50  )
    51  
    52  type SwarmFS struct {
    53  	swarmApi     *api.API
    54  	activeMounts map[string]*MountInfo
    55  	swarmFsLock  *sync.RWMutex
    56  }
    57  
    58  func NewSwarmFS(api *api.API) *SwarmFS {
    59  	swarmfsLock.Do(func() {
    60  		swarmfs = &SwarmFS{
    61  			swarmApi:     api,
    62  			swarmFsLock:  &sync.RWMutex{},
    63  			activeMounts: map[string]*MountInfo{},
    64  		}
    65  	})
    66  	return swarmfs
    67  
    68  }
    69  
    70  //
    71  func NewInode() uint64 {
    72  	inodeLock.Lock()
    73  	defer inodeLock.Unlock()
    74  	inode += 1
    75  	return inode
    76  }
    77