-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(responsemanager): process do not send first blocks
define extension and add processing to response manager
- Loading branch information
1 parent
b7be601
commit a4f1ac3
Showing
5 changed files
with
92 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package donotsendfirstblocks | ||
|
||
import ( | ||
basicnode "github.com/ipld/go-ipld-prime/node/basic" | ||
|
||
"github.com/ipfs/go-graphsync/ipldutil" | ||
) | ||
|
||
// EncodeDoNotSendFirstBlocks returns encoded cbor data for the given number | ||
// of blocks to skip | ||
func EncodeDoNotSendFirstBlocks(skipBlockCount int64) ([]byte, error) { | ||
nb := basicnode.Prototype.Int.NewBuilder() | ||
err := nb.AssignInt(skipBlockCount) | ||
if err != nil { | ||
return nil, err | ||
} | ||
nd := nb.Build() | ||
return ipldutil.EncodeNode(nd) | ||
} | ||
|
||
// DecodeDoNotSendFirstBlocks returns the number of blocks to skip | ||
func DecodeDoNotSendFirstBlocks(data []byte) (int64, error) { | ||
nd, err := ipldutil.DecodeNode(data) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return nd.AsInt() | ||
} |
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
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