mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-20 00:18:12 +08:00
Remove thirdparty/datastore2/delayed.go: part of new go-datastore
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
@ -5,11 +5,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
|
tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
|
||||||
datastore2 "github.com/ipfs/go-ipfs/thirdparty/datastore2"
|
|
||||||
|
|
||||||
delay "gx/ipfs/QmRJVNatYJwTAHgdSM1Xef9QVQ1Ch3XHdmcrykjP5Y4soL/go-ipfs-delay"
|
delay "gx/ipfs/QmRJVNatYJwTAHgdSM1Xef9QVQ1Ch3XHdmcrykjP5Y4soL/go-ipfs-delay"
|
||||||
testutil "gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
|
testutil "gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
|
||||||
ds "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore"
|
ds "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore"
|
||||||
|
delayed "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore/delayed"
|
||||||
ds_sync "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore/sync"
|
ds_sync "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore/sync"
|
||||||
p2ptestutil "gx/ipfs/QmYVR3C8DWPHdHxvLtNFYfjsXgaRAdh6hPMNH3KiwCgu4o/go-libp2p-netutil"
|
p2ptestutil "gx/ipfs/QmYVR3C8DWPHdHxvLtNFYfjsXgaRAdh6hPMNH3KiwCgu4o/go-libp2p-netutil"
|
||||||
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
|
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
|
||||||
@ -90,7 +90,7 @@ func MkSession(ctx context.Context, net tn.Network, p testutil.Identity) Instanc
|
|||||||
bsdelay := delay.Fixed(0)
|
bsdelay := delay.Fixed(0)
|
||||||
|
|
||||||
adapter := net.Adapter(p)
|
adapter := net.Adapter(p)
|
||||||
dstore := ds_sync.MutexWrap(datastore2.WithDelay(ds.NewMapDatastore(), bsdelay))
|
dstore := ds_sync.MutexWrap(delayed.New(ds.NewMapDatastore(), bsdelay))
|
||||||
|
|
||||||
bstore, err := blockstore.CachedBlockstore(ctx,
|
bstore, err := blockstore.CachedBlockstore(ctx,
|
||||||
blockstore.NewBlockstore(ds_sync.MutexWrap(dstore)),
|
blockstore.NewBlockstore(ds_sync.MutexWrap(dstore)),
|
||||||
|
47
thirdparty/datastore2/delayed.go
vendored
47
thirdparty/datastore2/delayed.go
vendored
@ -1,47 +0,0 @@
|
|||||||
package datastore2
|
|
||||||
|
|
||||||
import (
|
|
||||||
delay "gx/ipfs/QmRJVNatYJwTAHgdSM1Xef9QVQ1Ch3XHdmcrykjP5Y4soL/go-ipfs-delay"
|
|
||||||
ds "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore"
|
|
||||||
dsq "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore/query"
|
|
||||||
)
|
|
||||||
|
|
||||||
func WithDelay(ds ds.Datastore, delay delay.D) ds.Datastore {
|
|
||||||
return &delayed{ds: ds, delay: delay}
|
|
||||||
}
|
|
||||||
|
|
||||||
type delayed struct {
|
|
||||||
ds ds.Datastore
|
|
||||||
delay delay.D
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dds *delayed) Put(key ds.Key, value interface{}) (err error) {
|
|
||||||
dds.delay.Wait()
|
|
||||||
return dds.ds.Put(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dds *delayed) Get(key ds.Key) (value interface{}, err error) {
|
|
||||||
dds.delay.Wait()
|
|
||||||
return dds.ds.Get(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dds *delayed) Has(key ds.Key) (exists bool, err error) {
|
|
||||||
dds.delay.Wait()
|
|
||||||
return dds.ds.Has(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dds *delayed) Delete(key ds.Key) (err error) {
|
|
||||||
dds.delay.Wait()
|
|
||||||
return dds.ds.Delete(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dds *delayed) Query(q dsq.Query) (dsq.Results, error) {
|
|
||||||
dds.delay.Wait()
|
|
||||||
return dds.ds.Query(q)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dds *delayed) Batch() (ds.Batch, error) {
|
|
||||||
return ds.NewBasicBatch(dds), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ ds.Datastore = &delayed{}
|
|
Reference in New Issue
Block a user