forked from latticexyz/mud
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: v2 endpoint for pruned snapshot that returns entities as raw by…
…tes (latticexyz#215) * feat: v2 endpoint for pruned snapshot that returns entities as raw bytes * feat(network): integrate getStateLatestStreamPrunedV2 * fix(utils): handle hex array with length 0 * fix: use hexutil.Decode * fix: convert entity id uint8 array to string once * chore: debug invalid entity index * fix: use decodebig for parsing hex encoded entity id uint256 * feat(snapshot): add GetStateLatestStreamV2 endpoint * fix(network): call getStateLatestStreamV2 if no prune options are provided Co-authored-by: alvrs <alvarius@lattice.xyz>
- Loading branch information
Showing
8 changed files
with
601 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
package utils | ||
|
||
import ( | ||
"latticexyz/mud/packages/services/pkg/logger" | ||
|
||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func Min(a, b int) int { | ||
if a < b { | ||
return a | ||
} | ||
return b | ||
} | ||
|
||
func HexStringArrayToBytesArray(strArray []string) [][]byte { | ||
bytesArray := [][]byte{} | ||
for _, str := range strArray { | ||
entityIdBigInt, err := hexutil.DecodeBig(str) | ||
if err != nil { | ||
logger.GetLogger().Error("can't parse entity ID", zap.String("string", str), zap.Error(err)) | ||
} | ||
bytesArray = append(bytesArray, entityIdBigInt.Bytes()) | ||
} | ||
return bytesArray | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.