-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from cloudstruct/feature/chain-sync
Chain-sync mini-protocol (part 3)
- Loading branch information
Showing
12 changed files
with
384 additions
and
69 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 |
---|---|---|
|
@@ -14,3 +14,6 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Temporary dir for testing | ||
/tmp/ |
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,5 +1,26 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/fxamacker/cbor/v2" | ||
) | ||
|
||
const ( | ||
BLOCK_TYPE_ALLEGRA = 4 | ||
BLOCK_TYPE_ALLEGRA = 3 | ||
) | ||
|
||
type AllegraBlock struct { | ||
// Tells the CBOR decoder to convert to/from a struct and a CBOR array | ||
_ struct{} `cbor:",toarray"` | ||
Header ShelleyBlockHeader | ||
TransactionBodies []AllegraTransaction | ||
TransactionWitnessSets []ShelleyTransactionWitnessSet | ||
// TODO: figure out how to parse properly | ||
// We use RawMessage here because the content is arbitrary and can contain data that | ||
// cannot easily be represented in Go (such as maps with bytestring keys) | ||
TransactionMetadataSet map[uint]cbor.RawMessage | ||
} | ||
|
||
type AllegraTransaction struct { | ||
ShelleyTransaction | ||
ValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"` | ||
} |
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,5 +1,40 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/fxamacker/cbor/v2" | ||
) | ||
|
||
const ( | ||
BLOCK_TYPE_ALONZO = 5 | ||
) | ||
|
||
type AlonzoBlock struct { | ||
// Tells the CBOR decoder to convert to/from a struct and a CBOR array | ||
_ struct{} `cbor:",toarray"` | ||
Header ShelleyBlockHeader | ||
TransactionBodies []AlonzoTransaction | ||
TransactionWitnessSets []AlonzoTransactionWitnessSet | ||
// TODO: figure out how to parse properly | ||
// We use RawMessage here because the content is arbitrary and can contain data that | ||
// cannot easily be represented in Go (such as maps with bytestring keys) | ||
TransactionMetadataSet map[uint]cbor.RawMessage | ||
InvalidTransactions []uint | ||
} | ||
|
||
type AlonzoTransaction struct { | ||
MaryTransaction | ||
ScriptDataHash Blake2b256 `cbor:"11,keyasint,omitempty"` | ||
Collateral []ShelleyTransactionInput `cbor:"13,keyasint,omitempty"` | ||
RequiredSigners []Blake2b224 `cbor:"14,keyasint,omitempty"` | ||
NetworkId uint8 `cbor:"15,keyasint,omitempty"` | ||
} | ||
|
||
type AlonzoTransactionWitnessSet struct { | ||
ShelleyTransactionWitnessSet | ||
PlutusScripts interface{} `cbor:"3,keyasint,omitempty"` | ||
// TODO: figure out how to parse properly | ||
// We use RawMessage here because the content is arbitrary and can contain data that | ||
// cannot easily be represented in Go (such as maps with bytestring keys) | ||
PlutusData []cbor.RawMessage `cbor:"4,keyasint,omitempty"` | ||
Redeemers []cbor.RawMessage `cbor:"5,keyasint,omitempty"` | ||
} |
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,5 +1,39 @@ | ||
package block | ||
|
||
import ( | ||
// "fmt" | ||
"github.com/fxamacker/cbor/v2" | ||
) | ||
|
||
const ( | ||
BLOCK_TYPE_MARY = 3 | ||
BLOCK_TYPE_MARY = 4 | ||
) | ||
|
||
type MaryBlock struct { | ||
// Tells the CBOR decoder to convert to/from a struct and a CBOR array | ||
_ struct{} `cbor:",toarray"` | ||
Header ShelleyBlockHeader | ||
TransactionBodies []MaryTransaction | ||
TransactionWitnessSets []ShelleyTransactionWitnessSet | ||
// TODO: figure out how to parse properly | ||
// We use RawMessage here because the content is arbitrary and can contain data that | ||
// cannot easily be represented in Go (such as maps with bytestring keys) | ||
TransactionMetadataSet map[uint]cbor.RawMessage | ||
} | ||
|
||
type MaryTransaction struct { | ||
AllegraTransaction | ||
//Outputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"` | ||
Outputs []cbor.RawMessage `cbor:"1,keyasint,omitempty"` | ||
// TODO: further parsing of this field | ||
Mint cbor.RawMessage `cbor:"9,keyasint,omitempty"` | ||
} | ||
|
||
// TODO: support both forms | ||
/* | ||
transaction_output = [address, amount : value] | ||
value = coin / [coin,multiasset<uint>] | ||
*/ | ||
//type MaryTransactionOutput interface{} | ||
|
||
type MaryTransactionOutput cbor.RawMessage |
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.