Open lucasoares opened 7 months ago
when using the Solana SDK to filter requests (subscriptions, etc)
Can you tell me more?
when using the Solana SDK to filter requests (subscriptions, etc)
Can you tell me more?
Example of something I can't do with the current implementation if I use Uint128:
info := AmmInfo{}
subscription, err = wsConnection.ProgramSubscribeWithOpts(
<other parameters>,
[]rpc.RPCFilter{
{
DataSize: uint64(unsafe.Sizeof(info)),
},
{
Memcmp: &rpc.RPCFilterMemcmp{
Offset: uint64(unsafe.Offsetof(info.PcVaultMint)),
Bytes: SOL[:],
},
},
{
Memcmp: &rpc.RPCFilterMemcmp{
Offset: uint64(unsafe.Offsetof(info.MarketProgram)),
Bytes: open_book.MAINNET_OPENBOOK_MARKET[:],
},
},
},
)
If the AmmInfo
struct contains any UInt128
, the result of Sizeof
and Offsetof
will be incorrect.
If a struct contains
bin.Uint128
fields, the result ofunsafe.Sizeof
for the struct will be 16 bytes higher for eachbin.Uint128
field it contains... The result ofunsafe.Offsetof
will also differ based on the location of the struct's fields.How can we use
unsafe
helpers when using the Solana SDK to filter requests (subscriptions, etc) when using the Uint128?It seems this library is not a good option to use when working with Solana programs for now, but how can we make it be? For now I'm using a slice of uint64 with 2 positions to represent uint128 :(