Skip to content

Commit 2d02e5c

Browse files
committed
Sync quasar
1 parent 98eb7e7 commit 2d02e5c

File tree

119 files changed

+4245
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+4245
-729
lines changed

api/admin/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77
"context"
88

99
"github.com/luxfi/database/rpcdb"
10+
dbpb "github.com/luxfi/database/proto/pb/rpcdb"
1011
"github.com/luxfi/ids"
1112
"github.com/luxfi/node/api"
1213
"github.com/luxfi/node/utils/formatting"
1314
log "github.com/luxfi/log"
1415
"github.com/luxfi/node/utils/rpc"
15-
16-
dbpb "github.com/luxfi/database/proto/pb/rpcdb"
1716
)
1817

1918
type Client struct {

chains/atomic/gsharedmemory/consensus_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (c *ConsensusClient) Indexed(
5959
return resp.Values, resp.LastTrait, resp.LastKey, nil
6060
}
6161

62-
func (c *ConsensusClient) Apply(requests map[ids.ID]*quasar.Requests, batches ...interface{}) error {
62+
func (c *ConsensusClient) Apply(requests map[ids.ID]*quasar.Requests, batch quasar.Batch) error {
6363
req := &sharedmemorypb.ApplyRequest{
6464
Requests: make([]*sharedmemorypb.AtomicRequest, 0, len(requests)),
6565
Batches: make([]*sharedmemorypb.Batch, 0),

chains/atomic/gsharedmemory/sharedmemory_wrapper.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ type SharedMemoryWrapper struct {
1515
sm quasar.SharedMemory
1616
}
1717

18+
// batchWrapper wraps db.Batch to implement quasar.Batch
19+
type batchWrapper struct {
20+
db db.Batch
21+
}
22+
23+
func (b *batchWrapper) Write(key, value []byte) error {
24+
return b.db.Put(key, value)
25+
}
26+
27+
func (b *batchWrapper) Delete(key []byte) error {
28+
return b.db.Delete(key)
29+
}
30+
1831
// NewSharedMemoryWrapper creates a new wrapper
1932
func NewSharedMemoryWrapper(sm quasar.SharedMemory) atomic.SharedMemory {
2033
return &SharedMemoryWrapper{sm: sm}
@@ -48,10 +61,10 @@ func (w *SharedMemoryWrapper) Apply(requests map[ids.ID]*atomic.Requests, batche
4861
for chainID, req := range requests {
4962
consensusReq := &quasar.Requests{
5063
RemoveRequests: req.RemoveRequests,
51-
PutRequests: make([]quasar.Element, len(req.PutRequests)),
64+
PutRequests: make([]*quasar.Element, len(req.PutRequests)),
5265
}
5366
for i, elem := range req.PutRequests {
54-
consensusReq.PutRequests[i] = quasar.Element{
67+
consensusReq.PutRequests[i] = &quasar.Element{
5568
Key: elem.Key,
5669
Value: elem.Value,
5770
Traits: elem.Traits,
@@ -60,11 +73,12 @@ func (w *SharedMemoryWrapper) Apply(requests map[ids.ID]*atomic.Requests, batche
6073
consensusRequests[chainID] = consensusReq
6174
}
6275

63-
// Convert batches to interface{}
64-
interfaceBatches := make([]interface{}, len(batches))
65-
for i, batch := range batches {
66-
interfaceBatches[i] = batch
76+
// For now, we'll use the first batch if available
77+
var batch quasar.Batch
78+
if len(batches) > 0 {
79+
// Create a wrapper batch that delegates to the first db.Batch
80+
batch = &batchWrapper{db: batches[0]}
6781
}
6882

69-
return w.sm.Apply(consensusRequests, interfaceBatches...)
83+
return w.sm.Apply(consensusRequests, batch)
7084
}

chains/linearizable_vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
db "github.com/luxfi/database"
1212
"github.com/luxfi/ids"
1313
"github.com/luxfi/node/quasar"
14+
"github.com/luxfi/node/quasar/engine/chain/block"
1415
"github.com/luxfi/node/quasar/engine/core"
1516
"github.com/luxfi/node/quasar/engine/dag/vertex"
16-
"github.com/luxfi/node/quasar/engine/chain/block"
1717
"github.com/luxfi/node/version"
1818
)
1919

0 commit comments

Comments
 (0)